-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add tree dump utility to E2E test framework and fix Image border issue #3754
Changes from 16 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": "dida@ntdev.microsoft.com", | ||
"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: '100%', | ||||||||
width: '100%', | ||||||||
borderRadius: 10.0, | ||||||||
borderWidth:10, | ||||||||
borderColor: '#0000ff55', | ||||||||
backgroundColor: 'red', | ||||||||
}, | ||||||||
image: { | ||||||||
height: '100%', | ||||||||
width: '100%', | ||||||||
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} | ||||||||
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.
Suggested change
|
||||||||
testID={SHOW_IMAGE_BORDER}/> | ||||||||
<TreeDumpControl style={styles.treeDumpControl} dumpID={imageWithBorder?'ImageWithBorder':'ImageWithoutBorder'+clickCount} uiaID={IMAGE_CONTAINER} testID={TREE_DUMP_RESULT} /> | ||||||||
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.
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 commentThe 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) |
||||||||
</View>); | ||||||||
} |
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); | ||||||||
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 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) 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) 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); | ||||||||
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.
Suggested change
|
||||||||
|
||||||||
return testResult; | ||||||||
} | ||||||||
|
||||||||
protected timeoutForPageLoaded(currentTimeout?: number) { | ||||||||
if (currentTimeout) return currentTimeout; | ||||||||
return this.waitforPageTimeout; | ||||||||
|
@@ -44,6 +76,10 @@ export class BasePage { | |||||||
return this.isPageLoaded(); | ||||||||
} | ||||||||
|
||||||||
private get treeDumpResult() { | ||||||||
return By(TREE_DUMP_RESULT); | ||||||||
} | ||||||||
|
||||||||
// Default timeout for waitForPageLoaded command in PageObject | ||||||||
private waitforPageTimeout: number = 10000; | ||||||||
} |
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
[Windows.UI.Xaml.Controls.Border] | ||
ActualOffset=<0, 0, 0> | ||
Background=#FFFFFF00 | ||
BorderBrush=#5500FF00 | ||
BorderThickness=10,10,10,10 | ||
Clip=[NULL] | ||
CornerRadius=10,10,10,10 | ||
Height=300 | ||
HorizontalAlignment=Stretch | ||
Margin=0,0,0,0 | ||
Padding=0,0,0,0 | ||
RenderSize=500,300 | ||
VerticalAlignment=Stretch | ||
Visibility=Visible | ||
Width=500 | ||
[react.uwp.ViewPanel] | ||
ActualOffset=<10, 10, 0> | ||
Background=[NULL] | ||
BorderBrush=#5500FF00 | ||
BorderThickness=10,10,10,10 | ||
Clip=[NULL] | ||
CornerRadius=10,10,10,10 | ||
HorizontalAlignment=Stretch | ||
Margin=0,0,0,0 | ||
RenderSize=480,280 | ||
VerticalAlignment=Stretch | ||
Visibility=Visible | ||
[Windows.UI.Xaml.DependencyObject] |
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.