[fenix] Merge branch 'master' into a-s-networking
commit
a47300dfbc
@ -1,24 +0,0 @@
|
|||||||
package org.mozilla.fenix
|
|
||||||
|
|
||||||
import androidx.test.InstrumentationRegistry
|
|
||||||
import androidx.test.runner.AndroidJUnit4
|
|
||||||
|
|
||||||
import org.junit.Test
|
|
||||||
import org.junit.runner.RunWith
|
|
||||||
/* ktlint-disable no-wildcard-imports */
|
|
||||||
import org.junit.Assert.*
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Instrumented test, which will execute on an Android device.
|
|
||||||
*
|
|
||||||
* See [testing documentation](http://d.android.com/tools/testing).
|
|
||||||
*/
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
|
||||||
class ExampleInstrumentedTest {
|
|
||||||
@Test
|
|
||||||
fun useAppContext() {
|
|
||||||
// Context of the app under test.
|
|
||||||
val appContext = InstrumentationRegistry.getTargetContext()
|
|
||||||
assertEquals("org.mozilla.fenix", appContext.packageName)
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,7 @@
|
|||||||
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
package org.mozilla.fenix
|
||||||
|
|
||||||
|
class FirefoxTestApplication : HomeActivity()
|
@ -0,0 +1,16 @@
|
|||||||
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
package org.mozilla.fenix
|
||||||
|
|
||||||
|
import android.app.Application
|
||||||
|
import android.content.Context
|
||||||
|
import androidx.test.runner.AndroidJUnitRunner
|
||||||
|
|
||||||
|
class FirefoxTestRunner : AndroidJUnitRunner() {
|
||||||
|
|
||||||
|
override fun newApplication(cl: ClassLoader?, className: String?, context: Context?): Application {
|
||||||
|
return super.newApplication(cl, FirefoxTestApplication::class.java.name, context)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
package org.mozilla.fenix.helpers
|
||||||
|
|
||||||
|
import androidx.test.rule.ActivityTestRule
|
||||||
|
import org.mozilla.fenix.HomeActivity
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A [org.junit.Rule] to handle shared test set up for tests on [HomeActivity].
|
||||||
|
*
|
||||||
|
* @param initialTouchMode See [ActivityTestRule]
|
||||||
|
* @param launchActivity See [ActivityTestRule]
|
||||||
|
*/
|
||||||
|
|
||||||
|
class HomeActivityTestRule(initialTouchMode: Boolean = false, launchActivity: Boolean = true) :
|
||||||
|
ActivityTestRule<HomeActivity>(HomeActivity::class.java, initialTouchMode, launchActivity)
|
@ -0,0 +1,32 @@
|
|||||||
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
package org.mozilla.fenix.ui
|
||||||
|
|
||||||
|
import org.junit.Rule
|
||||||
|
import org.junit.Test
|
||||||
|
import org.mozilla.fenix.helpers.HomeActivityTestRule
|
||||||
|
import org.mozilla.fenix.ui.robots.homeScreen
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for verifying the presence of home screen elements
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
class HomeScreenTest {
|
||||||
|
/* ktlint-disable no-blank-line-before-rbrace */ // This imposes unreadable grouping.
|
||||||
|
@get:Rule
|
||||||
|
val activityTestRule = HomeActivityTestRule()
|
||||||
|
@Test
|
||||||
|
fun homeScreenItemsTest() {
|
||||||
|
homeScreen {
|
||||||
|
verifyHomeScreen()
|
||||||
|
verifyHomePrivateBrowsingButton()
|
||||||
|
verifyHomeMenu()
|
||||||
|
verifyHomeWordmark()
|
||||||
|
verifyHomeToolbar()
|
||||||
|
verifyHomeComponent()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
@file:Suppress("TooManyFunctions")
|
||||||
|
|
||||||
|
package org.mozilla.fenix.ui.robots
|
||||||
|
|
||||||
|
import androidx.test.espresso.Espresso.onView
|
||||||
|
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||||
|
import androidx.test.espresso.matcher.ViewMatchers
|
||||||
|
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
|
||||||
|
import androidx.test.espresso.matcher.ViewMatchers.Visibility
|
||||||
|
|
||||||
|
class HomeScreenRobot {
|
||||||
|
fun verifyHomeScreen() = homeScreen()
|
||||||
|
fun verifyHomePrivateBrowsingButton() = homePrivateBrowsingButton()
|
||||||
|
fun verifyHomeMenu() = homeMenu()
|
||||||
|
fun verifyHomeWordmark() = homeWordmark()
|
||||||
|
fun verifyHomeToolbar() = homeToolbar()
|
||||||
|
fun verifyHomeComponent() = homeComponent()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun homeScreen(interact: HomeScreenRobot.() -> Unit) {
|
||||||
|
HomeScreenRobot().interact()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun homeScreen() = onView(ViewMatchers.withResourceName("homeLayout"))
|
||||||
|
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||||
|
private fun homePrivateBrowsingButton() = onView(ViewMatchers.withResourceName("privateBrowsingButton"))
|
||||||
|
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||||
|
private fun homeMenu() = onView(ViewMatchers.withResourceName("menuButton"))
|
||||||
|
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||||
|
private fun homeWordmark() = onView(ViewMatchers.withResourceName("wordmark"))
|
||||||
|
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||||
|
private fun homeToolbar() = onView(ViewMatchers.withResourceName("toolbar"))
|
||||||
|
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||||
|
private fun homeComponent() = onView(ViewMatchers.withResourceName("home_component"))
|
||||||
|
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
Loading…
Reference in New Issue