-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add tree dump utility to E2E test framework and fix Image border issue #3754
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 15 commits
cc64ce1
c25021a
6c2916f
71fba93
01648c7
1c1d4c6
88f9b0e
91c43d2
2f91657
5275f13
30f6f96
9427f4c
8cf5ea5
dcd83d0
7180fb7
98a1282
ed5818a
b6aedd8
db8b680
ae7527d
44aebf8
84336b6
59ecc0f
84991ef
52a6a6f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "type": "prerelease", | ||
| "comment": "TreeDump for E2E test and fix for image border issue", | ||
| "packageName": "react-native-windows", | ||
| "email": "[email protected]", | ||
| "commit": "88f9b0eaecfe88e2243b66d969420131224f1c56", | ||
| "date": "2019-12-10T20:31:33.939Z" | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,70 @@ | ||||||||
| /** | ||||||||
| * Copyright (c) Microsoft Corporation. All rights reserved. | ||||||||
| * Licensed under the MIT License. | ||||||||
| */ | ||||||||
|
|
||||||||
| import {StyleSheet, View, Image, Button, requireNativeComponent} from 'react-native' | ||||||||
| import React, { useState } from 'react'; | ||||||||
| import { TREE_DUMP_RESULT, SHOW_IMAGE_BORDER, IMAGE_CONTAINER } from './Consts'; | ||||||||
| const TreeDumpControl = requireNativeComponent('TreeDumpControl'); | ||||||||
|
|
||||||||
| const styles = StyleSheet.create({ | ||||||||
| container: { | ||||||||
| height:300, | ||||||||
| width:500, | ||||||||
| backgroundColor: 'yellow', | ||||||||
| alignItems:'center', | ||||||||
| }, | ||||||||
| containerWithBorder: { | ||||||||
| height:300, | ||||||||
| width:500, | ||||||||
| borderRadius: 10.0, | ||||||||
| borderWidth:10, | ||||||||
| borderColor: '#00ff0055', | ||||||||
| backgroundColor: 'yellow', | ||||||||
| alignItems:'center', | ||||||||
| }, | ||||||||
| imageWithBorder: { | ||||||||
| height: 200, | ||||||||
| width: 300, | ||||||||
| borderRadius: 10.0, | ||||||||
| borderWidth:10, | ||||||||
| borderColor: '#0000ff55', | ||||||||
| backgroundColor: 'red', | ||||||||
| }, | ||||||||
| image: { | ||||||||
| height: 200, | ||||||||
| width: 300, | ||||||||
| backgroundColor: 'red', | ||||||||
| }, | ||||||||
| treeDumpControl: { | ||||||||
| height: 150, | ||||||||
| width: 500, | ||||||||
| margin: 10, | ||||||||
| }, | ||||||||
| }); | ||||||||
|
|
||||||||
| export function ImageTestPage() { | ||||||||
| const [imageWithBorder, setImageBorder] = useState(false); | ||||||||
| const [clickCount, setClickCount] = useState(0); | ||||||||
| const onOressBorder = () => { | ||||||||
| var previousImageBorderState = imageWithBorder; | ||||||||
| setImageBorder(!previousImageBorderState); | ||||||||
| var previousClickCount = clickCount; | ||||||||
| setClickCount(previousClickCount+1); | ||||||||
| } | ||||||||
| return( | ||||||||
| <View> | ||||||||
| <View testID={IMAGE_CONTAINER} style={imageWithBorder?styles.containerWithBorder:styles.container}> | ||||||||
| <Image | ||||||||
| style={imageWithBorder?styles.imageWithBorder:styles.image} | ||||||||
| resizeMode={'center'} | ||||||||
| source={{uri: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADMAAAAzCAYAAAA6oTAqAAAAEXRFWHRTb2Z0d2FyZQBwbmdjcnVzaEB1SfMAAABQSURBVGje7dSxCQBACARB+2/ab8BEeQNhFi6WSYzYLYudDQYGBgYGBgYGBgYGBgYGBgZmcvDqYGBgmhivGQYGBgYGBgYGBgYGBgYGBgbmQw+P/eMrC5UTVAAAAABJRU5ErkJggg=='}} | ||||||||
| /> | ||||||||
| </View > | ||||||||
| <Button title= {imageWithBorder?"Hide Border":"Show Border"} | ||||||||
| onPress={onOressBorder} | ||||||||
|
||||||||
| onPress={onOressBorder} | |
| onPress={onPressBorder} | |
| ``` #Resolved |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'ImageWithoutBorder'+clickCount [](start = 94, length = 31)
ImageWithoutBorder0.txt and ImageWithoutBorder2.txt is not readable, also you created a hard binding between ImageTestPage and Image.spec.ts. If you refactor the test case like changing the order or inserting a new click, it doesn't work anymore. #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am going to refactor the dumpID to "ImageWithoutBorder" and "ImageWithoutBorder-Subsequent", so it would work for click count > 2. The dump file is different if you initially don't have a border, or had a border then removed the border.
In reply to: 358381794 [](ancestors = 358381794)
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,12 +2,22 @@ | |||||||
| * Copyright (c) Microsoft Corporation. All rights reserved. | ||||||||
| * Licensed under the MIT License. | ||||||||
| */ | ||||||||
| import { REACT_CONTROL_ERROR_TEST_ID, HOME_BUTTON } from '../../app/Consts'; | ||||||||
| import { | ||||||||
| REACT_CONTROL_ERROR_TEST_ID, | ||||||||
| HOME_BUTTON, | ||||||||
| TREE_DUMP_RESULT, | ||||||||
| } from '../../app/Consts'; | ||||||||
|
|
||||||||
| export function By(testId: string): WebdriverIO.Element { | ||||||||
| return $('~' + testId); | ||||||||
| } | ||||||||
|
|
||||||||
| export function wait(timeout: number) { | ||||||||
| return new Promise(resolve => { | ||||||||
| setTimeout(resolve, timeout); | ||||||||
| }); | ||||||||
| } | ||||||||
|
|
||||||||
| export class BasePage { | ||||||||
| isPageLoaded(): boolean { | ||||||||
| return this.homeButton.isDisplayed(); | ||||||||
|
|
@@ -23,6 +33,28 @@ export class BasePage { | |||||||
| ); | ||||||||
| } | ||||||||
|
|
||||||||
| getTreeDumpResult() { | ||||||||
| var testResult = false; | ||||||||
| const maxWait = 20; | ||||||||
| var waitCount = 1; | ||||||||
| do { | ||||||||
| testResult = this.treeDumpResult.getText() == 'TreeDump:Passed'; | ||||||||
| if (!testResult) { | ||||||||
| console.log( | ||||||||
| '####Waiting for treedump comparison result ' + | ||||||||
| waitCount + | ||||||||
| '/' + | ||||||||
| maxWait + | ||||||||
| '...####' | ||||||||
| ); | ||||||||
| wait(100); | ||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there no event you can wait for? #Resolved
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was going to add event and wait for that, but we have issues with the optimized constructor with Context parameter on release build issue, so I decided to do polling for now. Will open a issue to revisit later after Jon fixes the Custom ViewManager bug. In reply to: 357846482 [](ancestors = 357846482)
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Feel free to open an issue to add a WaitForIdle or similar. In reply to: 357870760 [](ancestors = 357870760,357846482)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||
| waitCount += 1; | ||||||||
| } | ||||||||
| } while (waitCount <= maxWait && testResult == false); | ||||||||
|
||||||||
| } while (waitCount <= maxWait && testResult == false); | |
| } while (waitCount <= maxWait && !testResult); | |
| ``` #Resolved |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| /** | ||
| * Copyright (c) Microsoft Corporation. All rights reserved. | ||
| * Licensed under the MIT License. | ||
| */ | ||
|
|
||
| import { BasePage, By } from './BasePage'; | ||
| import { SHOW_IMAGE_BORDER } from '../../app/Consts'; | ||
|
|
||
| class ImageTestPage extends BasePage { | ||
| backToHomePage() { | ||
| this.homeButton.click(); | ||
| this.waitForPageLoaded(); | ||
| } | ||
|
|
||
| isPageLoaded() { | ||
| return super.isPageLoaded(); | ||
| } | ||
|
|
||
| toggleImageBorder() { | ||
| this._imageBorder.click(); | ||
| } | ||
|
|
||
| private get _imageBorder() { | ||
| return By(SHOW_IMAGE_BORDER); | ||
| } | ||
| } | ||
|
|
||
| export default new ImageTestPage(); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| /** | ||
| * Copyright (c) Microsoft Corporation. All rights reserved. | ||
| * Licensed under the MIT License. | ||
| */ | ||
|
|
||
| import HomePage from '../pages/HomePage'; | ||
| import ImageTestPage from '../pages/ImageTestPage'; | ||
| import assert from 'assert'; | ||
|
|
||
| beforeAll(() => { | ||
| HomePage.backToHomePage(); | ||
| HomePage.clickAndGotoImagePage(); | ||
| }); | ||
|
|
||
| describe('ImageWithoutBorderTest', () => { | ||
| it('ImageWithoutBorderTest', () => { | ||
| const result = ImageTestPage.getTreeDumpResult(); | ||
| assert(result, '#1. Dump comparison for image without border!'); | ||
| }); | ||
|
|
||
| it('ImageWithBorderTest', () => { | ||
| ImageTestPage.toggleImageBorder(); | ||
| const result = ImageTestPage.getTreeDumpResult(); | ||
| assert(result, '#2. Dump comparison for image with border!'); | ||
| }); | ||
|
|
||
| // toggle back to no border and verify border properties are reset | ||
| it('ImageWithoutBorderTest', () => { | ||
| ImageTestPage.toggleImageBorder(); | ||
| const result = ImageTestPage.getTreeDumpResult(); | ||
| assert(result, '#3. Second dump comparison for image without border!'); | ||
| }); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,8 @@ | |
| using Windows.UI.Xaml.Navigation; | ||
| using Microsoft.ReactNative; | ||
| using Windows.UI.Core; | ||
| using Windows.UI.ViewManagement; | ||
| using Windows.Foundation; | ||
|
|
||
| namespace ReactUWPTestApp | ||
| { | ||
|
|
@@ -42,6 +44,8 @@ public App() | |
| #endif | ||
|
|
||
| PackageProviders.Add(new Microsoft.ReactNative.Managed.ReactPackageProvider()); // Includes any modules in this project | ||
| PackageProviders.Add(new TreeDumpLibrary.ReactPackageProvider()); | ||
|
|
||
| this.InitializeComponent(); | ||
| } | ||
|
|
||
|
|
@@ -54,6 +58,7 @@ protected override void OnLaunched(LaunchActivatedEventArgs e) | |
| { | ||
| base.OnLaunched(e); | ||
| SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed; | ||
| ApplicationView.GetForCurrentView().TryResizeView(new Size(1024, 768)); | ||
|
||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.