mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 03:31:45 +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,
|
||||
"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": {
|
||||
"platformName": "iOS",
|
||||
"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"
|
||||
navigatingFrom="onNavigatingFrom"
|
||||
navigatedTo="onNavigatedTo"
|
||||
navigatedFrom="onNavigatedFrom"
|
||||
xmlns="http://schemas.nativescript.org/tns.xsd">
|
||||
|
||||
<ActionBar class="action-bar">
|
||||
navigatingFrom="onNavigatingFrom"
|
||||
navigatedTo="onNavigatedTo"
|
||||
navigatedFrom="onNavigatedFrom">
|
||||
|
||||
<ActionBar class="action-bar" id="action-bar-home-page" height="5%">
|
||||
<Label class="action-bar-title" text="Home"></Label>
|
||||
</ActionBar>
|
||||
|
||||
<StackLayout>
|
||||
<Button text="Show Modal Without Page" tap="onModalNoPage" />
|
||||
<Button text="Show Modal Page With Frame" tap="onModalFrame" />
|
||||
<Button text="Show Modal Page" tap="onModalPage" />
|
||||
<Button text="Show Modal Layout" tap="onModalLayout" />
|
||||
<Button text="Show Modal TabView" tap="onModalTabView" />
|
||||
<Button text="Navigate To Second Page" tap="onNavigate" />
|
||||
<Button text="Reset Frame Root View" tap="onFrameRootViewReset" />
|
||||
<Button text="Reset Tab Root View" tap="onTabRootViewReset" />
|
||||
<Button text="Reset Layout Root View" tap="onLayoutRootViewReset" />
|
||||
<Button text="Android Back Btn Events" tap="onAndroidBackEvents" />
|
||||
</StackLayout>
|
||||
<GridLayout rows="auto" columns="auto, *">
|
||||
<StackLayout id="home-page" row="0" col="0" borderColor="yellowgreen" borderWidth="1" borderRadius="5" padding="2">
|
||||
<TextView text="Reset root" />
|
||||
<Button text="Reset Frame Root View" tap="onFrameRootViewReset" textAlignment="left" />
|
||||
<Button text="Reset Tab Root View" tap="onTabRootViewReset" textAlignment="left" />
|
||||
<Button text="Reset Layout Root View" tap="onLayoutRootViewReset" textAlignment="left" />
|
||||
</StackLayout>
|
||||
<StackLayout id="home-page" row="0" col="1" borderColor="blue" borderWidth="1" borderRadius="5" marginLeft="2" padding="2">
|
||||
<TextView text="Navigate to example" />
|
||||
<Button text="Show Modal Without Page" tap="onModalNoPage" textAlignment="left" />
|
||||
<Button text="Show Modal Page With Frame" tap="onModalFrame" textAlignment="left" />
|
||||
<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>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<StackLayout backgroundColor="lightGreen" loaded="onLoaded">
|
||||
<Button text="Show Dialog" tap="showDialog"/>
|
||||
<Button text="Show Dialog" tap="showDialog" />
|
||||
<Button text="Close Modal" tap="closeModal" />
|
||||
</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 () {
|
||||
if (this.currentTest.state === "failed") {
|
||||
await driver.logPageSource(this.currentTest.title);
|
||||
await driver.logScreenshot(this.currentTest.title);
|
||||
await driver.logTestArtifacts(this.currentTest.title);
|
||||
await driver.resetApp();
|
||||
await screen[root]();
|
||||
}
|
||||
|
@ -36,8 +36,7 @@ describe("modal-layout:", () => {
|
||||
|
||||
afterEach(async function () {
|
||||
if (this.currentTest.state === "failed") {
|
||||
await driver.logPageSource(this.currentTest.title);
|
||||
await driver.logScreenshot(this.currentTest.title);
|
||||
await driver.logTestArtifacts(this.currentTest.title);
|
||||
await driver.resetApp();
|
||||
await screen[root]();
|
||||
}
|
||||
|
@ -35,8 +35,7 @@ describe("modal-page:", () => {
|
||||
|
||||
afterEach(async function () {
|
||||
if (this.currentTest.state === "failed") {
|
||||
await driver.logPageSource(this.currentTest.title);
|
||||
await driver.logScreenshot(this.currentTest.title);
|
||||
await driver.logTestArtifacts(this.currentTest.title);
|
||||
await driver.resetApp();
|
||||
await screen[root]();
|
||||
}
|
||||
|
@ -38,8 +38,7 @@ describe("modal-tab:", () => {
|
||||
|
||||
afterEach(async function () {
|
||||
if (this.currentTest.state === "failed") {
|
||||
await driver.logPageSource(this.currentTest.title);
|
||||
await driver.logScreenshot(this.currentTest.title);
|
||||
await driver.logTestArtifacts(this.currentTest.title);
|
||||
await driver.resetApp();
|
||||
await screen[root]();
|
||||
}
|
||||
|
@ -23,10 +23,12 @@
|
||||
"nativescript-dev-appium": "next",
|
||||
"nativescript-dev-typescript": "next",
|
||||
"nativescript-dev-webpack": "next",
|
||||
"rimraf": "^2.6.2",
|
||||
"typescript": "^3.0.3"
|
||||
},
|
||||
"scripts": {
|
||||
"e2e": "tsc -p e2e && mocha --opts ../config/mocha.opts --recursive e2e --appiumCapsLocation ../config/appium.capabilities.json",
|
||||
"e2e-watch": "tsc -p e2e --watch"
|
||||
"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",
|
||||
"clean-e2e": "rimraf 'e2e/**/*.js' 'e2e/**/*.js.map' 'e2e/**/*.map'"
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user