test: update test samples (#7016)

* test: update test samples
This commit is contained in:
Svetoslav
2019-03-20 18:15:48 +02:00
committed by GitHub
parent f9e008fd54
commit 2efafc3a4f
18 changed files with 139 additions and 80 deletions

View File

@ -8,7 +8,7 @@
</ActionBar> </ActionBar>
</Page.actionBar> </Page.actionBar>
<StackLayout> <StackLayout>
<Button text="go to cleared page" tap="navigate"/> <Button text="go to cleared page" automationText="goToClearedPage" tap="navigate"/>
<Button text="undefined" tap="onChangeRenderingMode"/> <Button text="undefined" tap="onChangeRenderingMode"/>
</StackLayout> </StackLayout>
</Page> </Page>

View File

@ -8,7 +8,7 @@
</ActionBar> </ActionBar>
</Page.actionBar> </Page.actionBar>
<StackLayout> <StackLayout>
<Button text="go to cleared page" tap="navigate"/> <Button text="go to cleared page" automationText="goToClearedPage" tap="navigate"/>
<Button text="undefined" tap="onChangeRenderingMode"/> <Button text="undefined" tap="onChangeRenderingMode"/>
</StackLayout> </StackLayout>
</Page> </Page>

View File

@ -1,17 +0,0 @@
import { EventData } from "tns-core-modules/data/observable";
import { SubMainPageViewModel } from "../sub-main-page-view-model";
import { WrapLayout } from "tns-core-modules/ui/layouts/wrap-layout";
import { Page } from "tns-core-modules/ui/page";
export function pageLoaded(args: EventData) {
const page = <Page>args.object;
const wrapLayout = <WrapLayout>page.getViewById("wrapLayoutWithExamples");
page.bindingContext = new SubMainPageViewModel(wrapLayout, loadExamples());
}
export function loadExamples() {
const examples = new Map<string, string>();
examples.set("open-file", "intent/open-file");
return examples;
}

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Page loaded="pageLoaded">
<ScrollView orientation="vertical" row="1">
<WrapLayout id="wrapLayoutWithExamples"/>
</ScrollView>
</Page>

View File

@ -1,5 +0,0 @@
<Page navigatingTo="navigatingTo">
<GridLayout id="root">
<Button text="Open File" tap="openFile" height="40"></Button>
</GridLayout>
</Page>

View File

@ -30,6 +30,7 @@ export function loadExamples() {
examples.set("ng-repo-1599", "issues/issue-ng-repo-1599"); examples.set("ng-repo-1599", "issues/issue-ng-repo-1599");
examples.set("ng-repo-1626", "issues/issue-ng-repo-1626"); examples.set("ng-repo-1626", "issues/issue-ng-repo-1626");
examples.set("6439", "issues/issue-6439"); examples.set("6439", "issues/issue-6439");
examples.set("open-file-6895", "issues/open-file-6895")
return examples; return examples;
} }

View File

@ -0,0 +1,5 @@
<Page navigatingTo="navigatingTo">
<GridLayout id="root">
<Button text="Open File" automationText="openFile" tap="openFile" height="40"></Button>
</GridLayout>
</Page>

View File

@ -1,19 +1,36 @@
export function onOuterWrapLayoutTap() { import { EventData, Page } from "tns-core-modules/ui/page/page";
console.log("on outer wrap layout tap"); import { Label } from "tns-core-modules/ui/label/label";
}
export function onStackLayoutThrowTap() { const setLabelTextAndLog = (args, text: string) => {
throw new Error("Should not tap layout with IsPassThroughParentEnabled=true"); const page = <Page>args.object.page;
} const label = <Label>page.getViewById("resultLabel");
label.set("text", text);
export function onUserInteractionDisabledTap() {
throw new Error("Should not tap button with IsUserInteractionEnabled=false");
}
export function onDisabledThrowTap() {
throw new Error("Should not tap button with IsEnabled=false");
}
export function onTap() {
console.log("on button tap"); console.log("on button tap");
} }
export function onTap(args: EventData) {
setLabelTextAndLog(args, "onButtonTapResult");
}
export function clearResult(args: EventData) {
setLabelTextAndLog(args, "none");
}
export function onOuterWrapLayoutTap(args) {
setLabelTextAndLog(args, "onOuterWrapLayoutTapResult");
}
export function onStackLayoutThrowTap(args: EventData) {
setLabelTextAndLog(args, "Should not tap layout with IsPassThroughParentEnabled=true");
// throw new Error("Should not tap layout with IsPassThroughParentEnabled=true");
}
export function onUserInteractionDisabledTap(args: EventData) {
setLabelTextAndLog(args, "Should not tap button with IsUserInteractionEnabled=false");
// throw new Error("Should not tap button with IsUserInteractionEnabled=false");
}
export function onDisabledThrowTap(args: EventData) {
setLabelTextAndLog(args, "Should not tap button with IsEnabled=false");
// throw new Error("Should not tap button with IsEnabled=false");
}

View File

@ -1,24 +1,28 @@
<Page class="page" actionBarHidden="true" xmlns="http://schemas.nativescript.org/tns.xsd"> <Page class="page" actionBarHidden="true"
xmlns="http://schemas.nativescript.org/tns.xsd">
<WrapLayout tap="onOuterWrapLayoutTap" backgroundColor="#bed3f4"> <WrapLayout tap="onOuterWrapLayoutTap" automationText="onOuterWrapLayoutTap" backgroundColor="#bed3f4" padding="5">
<StackLayout tap="onStackLayoutThrowTap" automationText="stackLayout1" backgroundColor="#f3f9db" height="180" isPassThroughParentEnabled="true">
<StackLayout tap="onStackLayoutThrowTap" backgroundColor="#f3f9db" height="200" isPassThroughParentEnabled="true"> <Label automationText="label1" text="isPassThroughParentEnabled='true'" isUserInteractionEnabled="false" />
<Label text="isPassThroughParentEnabled='true'" isUserInteractionEnabled="false" /> <Button automationText="onUserInteractionDisabledThrowTap1" isUserInteractionEnabled="false" tap="onUserInteractionDisabledThrowTap" text="isUserInteractionEnabled='false'"></Button>
<Button isUserInteractionEnabled="false" tap="onUserInteractionDisabledThrowTap" text="isUserInteractionEnabled='false'"></Button> <Button automationText="onDisabledThrowTap1" isEnabled="false" tap="onDisabledThrowTap" text="isEnabled='false'"></Button>
<Button isEnabled="false" tap="onDisabledThrowTap" text="isEnabled='false'"></Button> <Button tap="onTap" text="TAP" automationText="btn1"></Button>
<Button tap="onTap" text="TAP"></Button>
</StackLayout> </StackLayout>
<StackLayout tap="onStackLayoutThrowTap" style.margin="20" height="300" width="300" backgroundColor="#f5edf7" isPassThroughParentEnabled="true"> <StackLayout tap="onStackLayoutThrowTap" automationText="stackLayout2" style.margin="20" height="250" width="300" backgroundColor="#f5edf7" isPassThroughParentEnabled="true">
<Label text="isPassThroughParentEnabled='true'" isUserInteractionEnabled="false" /> <Label automationText="label2" text="isPassThroughParentEnabled='true'" isUserInteractionEnabled="false" />
<StackLayout tap="onStackLayoutThrowTap" backgroundColor="#f3f9db" height="200" isPassThroughParentEnabled="true"> <StackLayout tap="onStackLayoutThrowTap" automationText="stackLayout3" backgroundColor="#f3f9db" height="200" isPassThroughParentEnabled="true">
<Label text="isPassThroughParentEnabled='true'" isUserInteractionEnabled="false" /> <Label automationText="label3" text="isPassThroughParentEnabled='true'" isUserInteractionEnabled="false" />
<Button isUserInteractionEnabled="false" tap="onUserInteractionDisabledThrowTap" text="isUserInteractionEnabled='false'"></Button> <Button automationText="onUserInteractionDisabledThrowTap2" isUserInteractionEnabled="false" tap="onUserInteractionDisabledThrowTap" text="isUserInteractionEnabled='false'"></Button>
<Button isEnabled="false" tap="onDisabledThrowTap" text="isEnabled='false'"></Button> <Button automationText="onDisabledThrowTap2" isEnabled="false" tap="onDisabledThrowTap" text="isEnabled='false'"></Button>
<Button tap="onTap" text="TAP"></Button> <Button automationText="btn2" tap="onTap" text="TAP"></Button>
</StackLayout> </StackLayout>
</StackLayout> </StackLayout>
</WrapLayout> <Button text="x" automationText="clearResult" tap="clearResult" height="35" width="40" padding="0" />
<StackLayout>
<Label id="resultLabel" textWrap="true" />
</StackLayout>
</WrapLayout>
</Page> </Page>

View File

@ -36,7 +36,6 @@ export function pageLoaded(args: EventData) {
examples.set("progress-bar", "progress-bar/main-page"); examples.set("progress-bar", "progress-bar/main-page");
examples.set("date-picker", "date-picker/date-picker"); examples.set("date-picker", "date-picker/date-picker");
examples.set("nested-frames", "nested-frames/main-page"); examples.set("nested-frames", "nested-frames/main-page");
examples.set("intent", "intent/main-page");
page.bindingContext = new MainPageViewModel(wrapLayout, examples); page.bindingContext = new MainPageViewModel(wrapLayout, examples);
const parent = page.getViewById("parentLayout"); const parent = page.getViewById("parentLayout");

View File

@ -2,16 +2,16 @@
<ScrollView id="scroll-view"> <ScrollView id="scroll-view">
<StackLayout> <StackLayout>
<GridLayout rows="auto, auto, auto" backgroundColor="lightgray"> <GridLayout rows="auto, auto, auto" backgroundColor="lightgray">
<Button row="0" text="Change w/ Visibility" tap="{{ onChangeVisibility }}"></Button> <Button row="0" text="Change w/ Visibility" automationText="changeVisibilityTop" tap="{{ onChangeVisibility }}"></Button>
<Button row="1" text="Scroll To Bottom" tap="{{ onScrollToBottom }}"></Button> <Button row="1" text="Scroll To Bottom" automationText="scrollToBottom" tap="{{ onScrollToBottom }}"></Button>
<Label row="2" visibility="{{ isVisible ? 'visible' : 'collapsed' }}" text="{{ content }}" color="black"></Label> <Label row="2" visibility="{{ isVisible ? 'visible' : 'collapsed' }}" text="{{ content }}" color="black"></Label>
</GridLayout> </GridLayout>
<GridLayout height="2000" backgroundColor="yellow"></GridLayout> <GridLayout height="2000" backgroundColor="yellow"></GridLayout>
<GridLayout rows="auto, auto, auto" backgroundColor="lightgray"> <GridLayout rows="auto, auto, auto" backgroundColor="lightgray">
<Button row="0" text="Change w/ Visibility" tap="{{ onChangeVisibility }}"></Button> <Button row="0" text="Change w/ Visibility" automationText="changeVisibilityBottom" tap="{{ onChangeVisibility }}"></Button>
<Button row="1" text="Scroll To Top" tap="{{ onScrollToTop }}"></Button> <Button row="1" text="Scroll To Top" automationText="scrollToTop" tap="{{ onScrollToTop }}"></Button>
<Label row="2" visibility="{{ isVisible ? 'visible' : 'collapsed' }}" text="{{ content }}" color="black"></Label> <Label row="2" visibility="{{ isVisible ? 'visible' : 'collapsed' }}" text="{{ content }}" color="black"></Label>
</GridLayout> </GridLayout>
</StackLayout> </StackLayout>

View File

@ -1,21 +1,21 @@
<Page> <Page>
<TabView style="color: green;"> <TabView style="color: green;">
<TabView.items> <TabView.items>
<TabViewItem title="Title" iconSource="res://add_to_fav"> <TabViewItem title="Title" automationText="tab1" iconSource="res://add_to_fav">
<TabViewItem.view> <TabViewItem.view>
<GridLayout> <GridLayout>
<Label text="Title and icon" verticalAlignment="center" horizontalAlignment="center"/> <Label text="Title and icon" verticalAlignment="center" horizontalAlignment="center"/>
</GridLayout> </GridLayout>
</TabViewItem.view> </TabViewItem.view>
</TabViewItem> </TabViewItem>
<TabViewItem iconSource="res://add_to_fav"> <TabViewItem iconSource="res://add_to_fav" automationText="tab2" >
<TabViewItem.view> <TabViewItem.view>
<GridLayout> <GridLayout>
<Label text="Only icon" verticalAlignment="center" horizontalAlignment="center"/> <Label text="Only icon" verticalAlignment="center" horizontalAlignment="center"/>
</GridLayout> </GridLayout>
</TabViewItem.view> </TabViewItem.view>
</TabViewItem> </TabViewItem>
<TabViewItem title="Title"> <TabViewItem title="Title" automationText="tab3">
<TabViewItem.view> <TabViewItem.view>
<GridLayout> <GridLayout>
<Label text="Only title" verticalAlignment="center" horizontalAlignment="center"/> <Label text="Only title" verticalAlignment="center" horizontalAlignment="center"/>

View File

@ -7,7 +7,7 @@
<TabView id="tabViewContainer"> <TabView id="tabViewContainer">
<TabView.items> <TabView.items>
<TabViewItem title="Tab 1"> <TabViewItem title="Tab1" >
<TabViewItem.view> <TabViewItem.view>
<GridLayout rows="*, auto" columns="*"> <GridLayout rows="*, auto" columns="*">
<StackLayout row="0" backgroundColor="lightblue"></StackLayout> <StackLayout row="0" backgroundColor="lightblue"></StackLayout>
@ -15,7 +15,7 @@
</GridLayout> </GridLayout>
</TabViewItem.view> </TabViewItem.view>
</TabViewItem> </TabViewItem>
<TabViewItem title="Tab 2"> <TabViewItem title="Tab2" >
<TabViewItem.view> <TabViewItem.view>
<GridLayout rows="*, auto" columns="*"> <GridLayout rows="*, auto" columns="*">
<StackLayout row="0" backgroundColor="lightblue"></StackLayout> <StackLayout row="0" backgroundColor="lightblue"></StackLayout>

View File

@ -38,6 +38,11 @@ export function onNavigateToTabsBottomRoot(args: EventData) {
application._resetRootView({ moduleName: "tab-root/tab-bottom-root" }); application._resetRootView({ moduleName: "tab-root/tab-bottom-root" });
} }
export function onNavigateToSomePage(args: EventData) {
const button = <Button>args.object;
button.page.frame.navigate("some-page/some-page");
}
export function onFrameToNestedFrame(args: EventData) { export function onFrameToNestedFrame(args: EventData) {
const button = <Button>args.object; const button = <Button>args.object;
button.page.frame.navigate({ button.page.frame.navigate({

View File

@ -14,6 +14,7 @@
<Button text="Page w/ tabs (bottom)" tap="onNavigateToTabsBottomPage" /> <Button text="Page w/ tabs (bottom)" tap="onNavigateToTabsBottomPage" />
<Button text="Root tabs (top)" tap="onNavigateToTabsTopRoot" /> <Button text="Root tabs (top)" tap="onNavigateToTabsTopRoot" />
<Button text="Root tabs (bottom)" tap="onNavigateToTabsBottomRoot" /> <Button text="Root tabs (bottom)" tap="onNavigateToTabsBottomRoot" />
<Button text="Some page on root" automationText="somePageOnRoot" tap="onNavigateToSomePage" />
<Button text="Frame to NestedFrame (non-default transition)" tap="onFrameToNestedFrame" /> <Button text="Frame to NestedFrame (non-default transition)" tap="onFrameToNestedFrame" />
</StackLayout> </StackLayout>
</GridLayout> </GridLayout>

View File

@ -0,0 +1,55 @@
import { AppiumDriver, createDriver } from "nativescript-dev-appium";
import { Screen } from "./screen";
import { suspendTime, dontKeepActivities } from "./config";
describe("issues", () => {
let driver: AppiumDriver;
let screen: Screen;
before(async () => {
driver = await createDriver();
screen = new Screen(driver);
if (dontKeepActivities) {
await driver.setDontKeepActivities(true);
}
});
after(async () => {
if (dontKeepActivities) {
await driver.setDontKeepActivities(false);
}
await driver.quit();
console.log("Quit driver!");
});
afterEach(async function () {
if (this.currentTest.state === "failed") {
await driver.logTestArtifacts(this.currentTest.title);
await driver.resetApp();
}
});
it("issue-6488", async () => {
await screen.loadedHome();
const showSomePage = async () => {
const somePageBtn = await driver.waitForElement("somePageOnRoot");
await somePageBtn.tap();
await screen.loadedSomePage();
}
await showSomePage();
await driver.navBack();
await screen.loadedHome();
await driver.backgroundApp(suspendTime);
await showSomePage();
await driver.navBack();
await showSomePage();
await driver.navBack();
await screen.loadedHome();
});
});

View File

@ -278,7 +278,7 @@ export class Screen {
loadedHome = async () => { loadedHome = async () => {
const lblHome = await this._driver.waitForElement(home); const lblHome = await this._driver.waitForElement(home);
assert.isNotNull(lblHome); assert.isDefined(lblHome);
console.log(home + " loaded!"); console.log(home + " loaded!");
}; };
@ -329,7 +329,7 @@ export class Screen {
loadedPlayersList = async () => { loadedPlayersList = async () => {
const lblPlayerOne = await this._driver.waitForElement(playersData["playerOneDefault"].name); const lblPlayerOne = await this._driver.waitForElement(playersData["playerOneDefault"].name);
assert.isNotNull(lblPlayerOne); assert.isDefined(lblPlayerOne);
console.log(players + " loaded!"); console.log(players + " loaded!");
} }
@ -339,7 +339,7 @@ export class Screen {
loadedTeamsList = async () => { loadedTeamsList = async () => {
const lblTeamOne = await this._driver.waitForElement(teamsData["teamOneDefault"].name); const lblTeamOne = await this._driver.waitForElement(teamsData["teamOneDefault"].name);
assert.isNotNull(lblTeamOne); assert.isDefined(lblTeamOne);
console.log(teams + " loaded!"); console.log(teams + " loaded!");
} }
@ -349,7 +349,7 @@ export class Screen {
loadedElement = async (element: string) => { loadedElement = async (element: string) => {
const el = await this._driver.waitForElement(element); const el = await this._driver.waitForElement(element);
assert.isNotNull(el); assert.isDefined(el);
console.log(`${element} loaded!`); console.log(`${element} loaded!`);
}; };
@ -361,7 +361,7 @@ export class Screen {
private loadedPage = async (page: string) => { private loadedPage = async (page: string) => {
const lblPage = await this._driver.waitForElement(page); const lblPage = await this._driver.waitForElement(page);
assert.isNotNull(lblPage); assert.isDefined(lblPage);
console.log(page + " loaded!"); console.log(page + " loaded!");
}; };
@ -373,10 +373,10 @@ export class Screen {
private loadedItem = async (item: Item) => { private loadedItem = async (item: Item) => {
const lblItemName = await this._driver.waitForElement(item.name); const lblItemName = await this._driver.waitForElement(item.name);
assert.isNotNull(lblItemName); assert.isDefined(lblItemName);
const lblItemDescription = await this._driver.waitForElement(item.description); const lblItemDescription = await this._driver.waitForElement(item.description);
assert.isNotNull(lblItemDescription); assert.isDefined(lblItemDescription);
console.log(item.name + " loaded!"); console.log(item.name + " loaded!");
} }