From 2fc6eaf5d48cf22b6feeafeb67a44957887f2a40 Mon Sep 17 00:00:00 2001 From: isabelrios Date: Wed, 2 Oct 2019 14:57:14 +0200 Subject: [PATCH] fixing reviewers comments improve writing email and password in file --- .../syncintegration/SyncIntegrationTest.kt | 46 +++++++++---------- .../mozilla/fenix/syncintegration/conftest.py | 9 ++-- .../fenix/syncintegration/gradlewbuild.py | 7 --- .../fenix/syncintegration/launchSimScript.sh | 2 +- app/src/androidTest/resources/email.txt | 1 - app/src/androidTest/resources/password.txt | 1 - 6 files changed, 27 insertions(+), 39 deletions(-) diff --git a/app/src/androidTest/java/org/mozilla/fenix/syncintegration/SyncIntegrationTest.kt b/app/src/androidTest/java/org/mozilla/fenix/syncintegration/SyncIntegrationTest.kt index 0693c77df..dcb4cf13f 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/syncintegration/SyncIntegrationTest.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/syncintegration/SyncIntegrationTest.kt @@ -5,8 +5,8 @@ package org.mozilla.fenix.syncintegration import android.os.SystemClock.sleep -import android.widget.Button import android.widget.EditText + import androidx.test.espresso.Espresso.onView import androidx.test.espresso.action.ViewActions.click import androidx.test.espresso.action.ViewActions.replaceText @@ -26,6 +26,7 @@ import androidx.test.uiautomator.By import androidx.test.uiautomator.Until import org.hamcrest.Matchers.allOf import org.mozilla.fenix.R +import org.mozilla.fenix.helpers.TestAssetHelper @Suppress("RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS") class SyncIntegrationTest { @@ -40,9 +41,9 @@ class SyncIntegrationTest { signInFxSync() tapReturnToPreviousApp() homeScreen { - }.openThreeDotMenu {} - libraryButton() - historyButton() + }.openThreeDotMenu { + }.openLibrary { + }.openHistory { } historyAfterSyncIsShown() } /* These tests will be running in the future @@ -54,11 +55,10 @@ class SyncIntegrationTest { fun checkBookmarkFromDesktopTest() { signInFxSync() tapReturnToPreviousApp() - sleep(5000) homeScreen { - }.openThreeDotMenu {} - libraryButton() - bookmarkButton() + }.openThreeDotMenu { + }.openLibrary { + }.openBookmarks { } bookmarkAfterSyncIsShown() } @@ -77,7 +77,7 @@ class SyncIntegrationTest { fun checkHistoryFromDeviceTest() { tapInToolBar() typeInToolBar() - sleep(3000) + sleep(TestAssetHelper.waitingTime) mDevice.pressBack() signInFxSync() } @@ -88,7 +88,7 @@ class SyncIntegrationTest { val emailInput = mDevice.findObject(UiSelector() .instance(0) .className(EditText::class.java)) - emailInput.waitForExists(1000) + emailInput.waitForExists(TestAssetHelper.waitingTime) val emailAddress = javaClass.classLoader.getResource("email.txt").readText() emailInput.setText(emailAddress) @@ -96,7 +96,7 @@ class SyncIntegrationTest { fun tapOnContinueButton() { val continueButton = mDevice.findObject(By.res("submit-btn")) - continueButton.clickAndWait(Until.newWindow(), 50000) + continueButton.clickAndWait(Until.newWindow(), TestAssetHelper.waitingTime) } fun typePassowrd() { @@ -109,13 +109,10 @@ class SyncIntegrationTest { } fun tapOnSygIn() { + mDevice.wait(Until.findObjects(By.text("Sign in")), TestAssetHelper.waitingTime) + // Let's tap on enter, sometimes depending on the device the sign in button is + // hidden by the keyboard mDevice.pressEnter() - mDevice.wait(Until.findObjects(By.text("Sign in")), 3000) - val signInButton = mDevice.findObject(UiSelector() - .instance(0) - .className(Button::class.java)) - signInButton.waitForExists(10000) - signInButton.click() } fun typeInToolBar() { @@ -134,18 +131,20 @@ class SyncIntegrationTest { } fun seeBookmark() { - mDevice.wait(Until.findObjects(By.text("Bookmark")), 3000) + mDevice.wait(Until.findObjects(By.text("Bookmark")), TestAssetHelper.waitingTime) val bookmarkButton = mDevice.findObject(By.text("Bookmark")) bookmarkButton.click() } fun tapReturnToPreviousApp() { - mDevice.wait(Until.findObjects(By.text("Connected")), 2000) + mDevice.wait(Until.findObjects(By.text("Connected")), TestAssetHelper.waitingTime) - val settingsLabel = mDevice.wait(Until.findObject(By.text("Settings")), 20000) + val settingsLabel = mDevice.wait(Until.findObject(By.text("Settings")), TestAssetHelper.waitingTime) settingsLabel.isClickable() - mDevice.pressBack() + mDevice.wait(Until.findObjects(By.desc("Navigate up")), TestAssetHelper.waitingTime) + val backButton = mDevice.findObject(By.desc("Navigate up")) + backButton.click() } fun signInFxSync() { @@ -159,7 +158,7 @@ class SyncIntegrationTest { typeEmail() tapOnContinueButton() typePassowrd() - sleep(3000) + sleep(TestAssetHelper.waitingTime) tapOnSygIn() } } @@ -167,7 +166,4 @@ class SyncIntegrationTest { fun settingsAccount() = onView(allOf(withText("Turn on Sync"))).perform(click()) fun tapInToolBar() = onView(withId(org.mozilla.fenix.R.id.toolbar_wrapper)) fun awesomeBar() = onView(withId(org.mozilla.fenix.R.id.mozac_browser_toolbar_edit_url_view)) -fun libraryButton() = onView(allOf(withText(R.string.browser_menu_your_library))).perform(click()) -fun historyButton() = onView(allOf(withText("History"))).perform(click()) -fun bookmarkButton() = onView(allOf(withText("Bookmarks"))).perform(click()) fun useEmailInsteadButton() = onView(withId(R.id.signInEmailButton)).perform(click()) diff --git a/app/src/androidTest/java/org/mozilla/fenix/syncintegration/conftest.py b/app/src/androidTest/java/org/mozilla/fenix/syncintegration/conftest.py index 7073bebd3..a80590bff 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/syncintegration/conftest.py +++ b/app/src/androidTest/java/org/mozilla/fenix/syncintegration/conftest.py @@ -58,10 +58,11 @@ def tps_addon(pytestconfig, tmpdir_factory): def tps_config(fxa_account, monkeypatch): monkeypatch.setenv('FXA_EMAIL', fxa_account.email) monkeypatch.setenv('FXA_PASSWORD', fxa_account.password) - f= open("/Users/synctesting/.jenkins/workspace/fenix@2/app/src/androidTest/resources/email.txt","w+") - f.write(fxa_account.email) - f= open("/Users/synctesting/.jenkins/workspace/fenix@2/app/src/androidTest/resources/password.txt","w+") - f.write(fxa_account.password) + with open ("/Users/synctesting/.jenkins/workspace/fenix/app/src/androidTest/resources/email.txt", "w") as f: + f.write(fxa_account.email) + + with open ("/Users/synctesting/.jenkins/workspace/fenix/app/src/androidTest/resources/password.txt", "w") as f: + f.write(fxa_account.password) yield {'fx_account': { 'username': fxa_account.email, diff --git a/app/src/androidTest/java/org/mozilla/fenix/syncintegration/gradlewbuild.py b/app/src/androidTest/java/org/mozilla/fenix/syncintegration/gradlewbuild.py index 65f97b3c4..a02d8743e 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/syncintegration/gradlewbuild.py +++ b/app/src/androidTest/java/org/mozilla/fenix/syncintegration/gradlewbuild.py @@ -18,16 +18,9 @@ class GradlewBuild(object): def test(self, identifier): self.adbrun.launch() - #self.xcrun.launch() # Change path accordingly to go to root folder to run gradlew os.chdir('../../../../../../../..') args = './gradlew ' + 'app:connectedGeckoNightlyDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=org.mozilla.fenix.syncintegration.SyncIntegrationTest#{}'.format(identifier) - # os.system(args) - # Whit this the logs are shown when there is a failure - # they are saved in ~/fenix/app/build/reports/androidTests/connected/flavors/X86/index.html - # output = subprocess.check_output(args, shell=True) - - # This part below does not work yet... self.logger.info('Running: {}'.format(' '.join(args))) try: diff --git a/app/src/androidTest/java/org/mozilla/fenix/syncintegration/launchSimScript.sh b/app/src/androidTest/java/org/mozilla/fenix/syncintegration/launchSimScript.sh index 937d804dd..648397f0e 100755 --- a/app/src/androidTest/java/org/mozilla/fenix/syncintegration/launchSimScript.sh +++ b/app/src/androidTest/java/org/mozilla/fenix/syncintegration/launchSimScript.sh @@ -2,7 +2,7 @@ set -e echo "Waiting emulator is ready..." -~/Library/Android/sdk/emulator/emulator -avd Pixel_API_28 -wipe-data -no-boot-anim -screen no-touch & +~/Library/Android/sdk/emulator/emulator -avd Pixel_3_API_28 -wipe-data -no-boot-anim -screen no-touch & bootanim="" failcounter=0 diff --git a/app/src/androidTest/resources/email.txt b/app/src/androidTest/resources/email.txt index e801045fd..e69de29bb 100644 --- a/app/src/androidTest/resources/email.txt +++ b/app/src/androidTest/resources/email.txt @@ -1 +0,0 @@ -pytest-28f90ad8b4@restmail.net \ No newline at end of file diff --git a/app/src/androidTest/resources/password.txt b/app/src/androidTest/resources/password.txt index a1bd28106..e69de29bb 100644 --- a/app/src/androidTest/resources/password.txt +++ b/app/src/androidTest/resources/password.txt @@ -1 +0,0 @@ -yArgpjhB \ No newline at end of file