mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 20:11:24 +08:00
tests: include e2e test for "Android Back Btn Events" (#6269)
* tests: include e2e test for "Android Back Btn Events"
This commit is contained in:
@ -83,6 +83,18 @@
|
|||||||
"fullReset": false,
|
"fullReset": false,
|
||||||
"app": ""
|
"app": ""
|
||||||
},
|
},
|
||||||
|
"android28": {
|
||||||
|
"platformName": "Android",
|
||||||
|
"platformVersion": "28",
|
||||||
|
"deviceName": "Emulator-Api28-Google",
|
||||||
|
"avd": "Emulator-Api28-Google",
|
||||||
|
"lt": 60000,
|
||||||
|
"appActivity": "com.tns.NativeScriptActivity",
|
||||||
|
"newCommandTimeout": 720,
|
||||||
|
"noReset": true,
|
||||||
|
"fullReset": false,
|
||||||
|
"app": ""
|
||||||
|
},
|
||||||
"sim.iPhone7.iOS110": {
|
"sim.iPhone7.iOS110": {
|
||||||
"platformName": "iOS",
|
"platformName": "iOS",
|
||||||
"platformVersion": "11.2",
|
"platformVersion": "11.2",
|
||||||
|
19
e2e/modal-navigation/app/app.android.css
Normal file
19
e2e/modal-navigation/app/app.android.css
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#home-page {
|
||||||
|
font-size: 8;
|
||||||
|
margin: 0px;
|
||||||
|
padding: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#action-bar-home-page{
|
||||||
|
font-size: 10;
|
||||||
|
margin: 0px;
|
||||||
|
padding: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#home-page Button {
|
||||||
|
margin-bottom: 5px;
|
||||||
|
border-color: gray;
|
||||||
|
border-width: 2px;
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 0px;
|
||||||
|
}
|
@ -1,13 +0,0 @@
|
|||||||
/*
|
|
||||||
In NativeScript, the app.css file is where you place CSS rules that
|
|
||||||
you would like to apply to your entire application. Check out
|
|
||||||
http://docs.nativescript.org/ui/styling for a full list of the CSS
|
|
||||||
selectors and properties you can use to style UI components.
|
|
||||||
|
|
||||||
/*
|
|
||||||
For example, the following CSS rule changes the font size of all UI
|
|
||||||
components that have the btn class name.
|
|
||||||
*/
|
|
||||||
.btn {
|
|
||||||
font-size: 18;
|
|
||||||
}
|
|
||||||
|
14
e2e/modal-navigation/app/app.ios.css
Normal file
14
e2e/modal-navigation/app/app.ios.css
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
|
||||||
|
#home-page {
|
||||||
|
font-size: 13;
|
||||||
|
margin: 0px;
|
||||||
|
padding: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#home-page Button {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
padding: 20px;
|
||||||
|
border-color: gray;
|
||||||
|
border-width: 2px;
|
||||||
|
border-radius: 8px;
|
||||||
|
}
|
@ -1,24 +1,28 @@
|
|||||||
<Page class="page"
|
<Page xmlns="http://schemas.nativescript.org/tns.xsd" class="page"
|
||||||
navigatingTo="onNavigatingTo"
|
navigatingTo="onNavigatingTo"
|
||||||
navigatingFrom="onNavigatingFrom"
|
navigatingFrom="onNavigatingFrom"
|
||||||
navigatedTo="onNavigatedTo"
|
navigatedTo="onNavigatedTo"
|
||||||
navigatedFrom="onNavigatedFrom"
|
navigatedFrom="onNavigatedFrom">
|
||||||
xmlns="http://schemas.nativescript.org/tns.xsd">
|
|
||||||
|
<ActionBar class="action-bar" id="action-bar-home-page" height="5%">
|
||||||
<ActionBar class="action-bar">
|
|
||||||
<Label class="action-bar-title" text="Home"></Label>
|
<Label class="action-bar-title" text="Home"></Label>
|
||||||
</ActionBar>
|
</ActionBar>
|
||||||
|
|
||||||
<StackLayout>
|
<GridLayout rows="auto" columns="auto, *">
|
||||||
<Button text="Show Modal Without Page" tap="onModalNoPage" />
|
<StackLayout id="home-page" row="0" col="0" borderColor="yellowgreen" borderWidth="1" borderRadius="5" padding="2">
|
||||||
<Button text="Show Modal Page With Frame" tap="onModalFrame" />
|
<TextView text="Reset root" />
|
||||||
<Button text="Show Modal Page" tap="onModalPage" />
|
<Button text="Reset Frame Root View" tap="onFrameRootViewReset" textAlignment="left" />
|
||||||
<Button text="Show Modal Layout" tap="onModalLayout" />
|
<Button text="Reset Tab Root View" tap="onTabRootViewReset" textAlignment="left" />
|
||||||
<Button text="Show Modal TabView" tap="onModalTabView" />
|
<Button text="Reset Layout Root View" tap="onLayoutRootViewReset" textAlignment="left" />
|
||||||
<Button text="Navigate To Second Page" tap="onNavigate" />
|
</StackLayout>
|
||||||
<Button text="Reset Frame Root View" tap="onFrameRootViewReset" />
|
<StackLayout id="home-page" row="0" col="1" borderColor="blue" borderWidth="1" borderRadius="5" marginLeft="2" padding="2">
|
||||||
<Button text="Reset Tab Root View" tap="onTabRootViewReset" />
|
<TextView text="Navigate to example" />
|
||||||
<Button text="Reset Layout Root View" tap="onLayoutRootViewReset" />
|
<Button text="Show Modal Without Page" tap="onModalNoPage" textAlignment="left" />
|
||||||
<Button text="Android Back Btn Events" tap="onAndroidBackEvents" />
|
<Button text="Show Modal Page With Frame" tap="onModalFrame" textAlignment="left" />
|
||||||
</StackLayout>
|
<Button text="Show Modal Page" tap="onModalPage" textAlignment="left" />
|
||||||
|
<Button text="Show Modal Layout" tap="onModalLayout" textAlignment="left" />
|
||||||
|
<Button text="Show Modal TabView" tap="onModalTabView" textAlignment="left" />
|
||||||
|
<Button text="Android Back Btn Events" tap="onAndroidBackEvents" textAlignment="left" />
|
||||||
|
</StackLayout>
|
||||||
|
</GridLayout>
|
||||||
</Page>
|
</Page>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<StackLayout backgroundColor="lightGreen" loaded="onLoaded">
|
<StackLayout backgroundColor="lightGreen" loaded="onLoaded">
|
||||||
<Button text="Show Dialog" tap="showDialog"/>
|
<Button text="Show Dialog" tap="showDialog" />
|
||||||
<Button text="Close Modal" tap="closeModal" />
|
<Button text="Close Modal" tap="closeModal" />
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
|
39
e2e/modal-navigation/e2e/android-back-button.e2e-spec.ts
Normal file
39
e2e/modal-navigation/e2e/android-back-button.e2e-spec.ts
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
import { AppiumDriver, createDriver, SearchOptions } from "nativescript-dev-appium";
|
||||||
|
import { Screen } from "./screen"
|
||||||
|
import { assert } from "chai";
|
||||||
|
|
||||||
|
const exampleAndroidBackBtnEvents = "Android Back Btn Events";
|
||||||
|
|
||||||
|
describe("android-navigate-back", () => {
|
||||||
|
let driver: AppiumDriver;
|
||||||
|
let screen: Screen;
|
||||||
|
|
||||||
|
before(async () => {
|
||||||
|
driver = await createDriver();
|
||||||
|
screen = new Screen(driver);
|
||||||
|
const btnShowNestedModalFrame = await driver.findElementByText(exampleAndroidBackBtnEvents);
|
||||||
|
await btnShowNestedModalFrame.click();
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(async function () {
|
||||||
|
if (this.currentTest.state === "failed") {
|
||||||
|
await driver.logTestArtifacts(this.currentTest.title);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
after(async () => {
|
||||||
|
await driver.resetApp();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should skip first navigate back", async function () {
|
||||||
|
if (driver.isIOS) {
|
||||||
|
this.skip();
|
||||||
|
}
|
||||||
|
|
||||||
|
await driver.navBack();
|
||||||
|
const textElement = await driver.findElementsByText("will cancel next back press: false", SearchOptions.contains, 10);
|
||||||
|
assert.isTrue(textElement !== null);
|
||||||
|
await driver.navBack();
|
||||||
|
await screen.loadedHome();
|
||||||
|
})
|
||||||
|
})
|
@ -33,8 +33,7 @@ describe("modal-frame:", () => {
|
|||||||
|
|
||||||
afterEach(async function () {
|
afterEach(async function () {
|
||||||
if (this.currentTest.state === "failed") {
|
if (this.currentTest.state === "failed") {
|
||||||
await driver.logPageSource(this.currentTest.title);
|
await driver.logTestArtifacts(this.currentTest.title);
|
||||||
await driver.logScreenshot(this.currentTest.title);
|
|
||||||
await driver.resetApp();
|
await driver.resetApp();
|
||||||
await screen[root]();
|
await screen[root]();
|
||||||
}
|
}
|
||||||
|
@ -36,8 +36,7 @@ describe("modal-layout:", () => {
|
|||||||
|
|
||||||
afterEach(async function () {
|
afterEach(async function () {
|
||||||
if (this.currentTest.state === "failed") {
|
if (this.currentTest.state === "failed") {
|
||||||
await driver.logPageSource(this.currentTest.title);
|
await driver.logTestArtifacts(this.currentTest.title);
|
||||||
await driver.logScreenshot(this.currentTest.title);
|
|
||||||
await driver.resetApp();
|
await driver.resetApp();
|
||||||
await screen[root]();
|
await screen[root]();
|
||||||
}
|
}
|
||||||
|
@ -35,8 +35,7 @@ describe("modal-page:", () => {
|
|||||||
|
|
||||||
afterEach(async function () {
|
afterEach(async function () {
|
||||||
if (this.currentTest.state === "failed") {
|
if (this.currentTest.state === "failed") {
|
||||||
await driver.logPageSource(this.currentTest.title);
|
await driver.logTestArtifacts(this.currentTest.title);
|
||||||
await driver.logScreenshot(this.currentTest.title);
|
|
||||||
await driver.resetApp();
|
await driver.resetApp();
|
||||||
await screen[root]();
|
await screen[root]();
|
||||||
}
|
}
|
||||||
|
@ -38,8 +38,7 @@ describe("modal-tab:", () => {
|
|||||||
|
|
||||||
afterEach(async function () {
|
afterEach(async function () {
|
||||||
if (this.currentTest.state === "failed") {
|
if (this.currentTest.state === "failed") {
|
||||||
await driver.logPageSource(this.currentTest.title);
|
await driver.logTestArtifacts(this.currentTest.title);
|
||||||
await driver.logScreenshot(this.currentTest.title);
|
|
||||||
await driver.resetApp();
|
await driver.resetApp();
|
||||||
await screen[root]();
|
await screen[root]();
|
||||||
}
|
}
|
||||||
|
@ -23,10 +23,12 @@
|
|||||||
"nativescript-dev-appium": "next",
|
"nativescript-dev-appium": "next",
|
||||||
"nativescript-dev-typescript": "next",
|
"nativescript-dev-typescript": "next",
|
||||||
"nativescript-dev-webpack": "next",
|
"nativescript-dev-webpack": "next",
|
||||||
|
"rimraf": "^2.6.2",
|
||||||
"typescript": "^3.0.3"
|
"typescript": "^3.0.3"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"e2e": "tsc -p e2e && mocha --opts ../config/mocha.opts --recursive e2e --appiumCapsLocation ../config/appium.capabilities.json",
|
"e2e": "npm run clean-e2e && tsc -p e2e && mocha --opts ../config/mocha.opts --recursive e2e --appiumCapsLocation ../config/appium.capabilities.json",
|
||||||
"e2e-watch": "tsc -p e2e --watch"
|
"e2e-watch": "tsc -p e2e --watch",
|
||||||
|
"clean-e2e": "rimraf 'e2e/**/*.js' 'e2e/**/*.js.map' 'e2e/**/*.map'"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user