-
- All Implemented Interfaces:
-
com.kaspersky.kaspresso.testcases.core.testassistants.TestAssistantsProvider
public abstract class DocLocScreenshotTestCase extends TestCase
The base class for all docloc screenshot tests.
Project-wide ScreenshotTestCase should be implemented as following:
open class ProductDocLocScreenshotTestCase(testName: String) : DocLocScreenshotTestCase( File(testName), "comma-separated string of locales" ) { @get:Rule val activityTestRule = ActivityTestRule(FragmentTestActivity::class.java, true, false) protected lateinit var activity: FragmentTestActivity @Before open fun setUp() { activity = activityTestRule.launchActivity(null) } }Screenshoter test extends the project-wide class:
@ScreenShooterTest class FeatureScreenshot : ProductDocLocScreenshotTestCase("feature_screenshot") { @Test fun featureScreen() { val featureView = FeatureFragment.newInstance() activity.setFragment(featureView) val view = getUiSafeProxy<FeatureView>(featureView) // Explicit type is important and must be interface view.showLoading() captureScreenshot("screenshot_description") } }As you might have noticed, activity test rule is launched with
``FragmentTestActivity``. It's a special per-project empty activity for test with``setFragment(Fragment)``method. E.g:class FragmentTestActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_fragment_container) } fun setFragment(fragment: Fragment) { val fragmentTransaction = supportFragmentManager.beginTransaction() fragmentTransaction.replace(R.id.content_container, fragment, "") fragmentTransaction.build() } }
-
-
Field Summary
Fields Modifier and Type Field Description private final LocaleRulelocaleRuleprivate final GrantPermissionRulestoragePermissionRuleprivate final TestFailRuletestFailRuleprivate final StringtestCaseNameprivate final TestAssistantsProviderImpltestAssistantsProviderprivate final AdbServeradbServerprivate final Devicedeviceprivate final UiTestLoggertestLoggerprivate final Paramsparamsprivate final Function1<Function1<Unit, Unit>, Unit>dataProducerprivate final List<MainSectionEnricher<Unit>>mainSectionEnrichers
-
Constructor Summary
Constructors Constructor Description DocLocScreenshotTestCase(File screenshotsDirectory, ScreenshotDirectoryProvider screenshotDirectoryProvider, ScreenshotNameProvider screenshotNameProvider, Boolean changeSystemLocale, String locales, Kaspresso.Builder kaspressoBuilder)
-
Method Summary
Modifier and Type Method Description final Unitsetup()final <I extends Any> IgetUiSafeProxy(I view)Return a dynamic proxy for a given view. final <T extends Any> ObjectgetUiSafeProxyFromImplementation(T view)Return a dynamic proxy over all interfaces that view implements. final LocaleRulegetLocaleRule()final GrantPermissionRulegetStoragePermissionRule()final TestFailRulegetTestFailRule()final StringgetTestCaseName()final TestAssistantsProviderImplgetTestAssistantsProvider()AdbServergetAdbServer()DevicegetDevice()UiTestLoggergetTestLogger()ParamsgetParams()final Function1<Function1<Unit, Unit>, Unit>getDataProducer()final List<MainSectionEnricher<Unit>>getMainSectionEnrichers()-
Methods inherited from class com.kaspersky.kaspresso.testcases.api.testcase.TestCase
createBaseTestBodyBuilder -
Methods inherited from class com.kaspersky.kaspresso.testcases.core.testassistants.TestAssistantsProvider
equals, hashCode, toString -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
DocLocScreenshotTestCase
DocLocScreenshotTestCase(File screenshotsDirectory, ScreenshotDirectoryProvider screenshotDirectoryProvider, ScreenshotNameProvider screenshotNameProvider, Boolean changeSystemLocale, String locales, Kaspresso.Builder kaspressoBuilder)
- Parameters:
screenshotsDirectory- root directory to save screenshot.screenshotDirectoryProvider- screenshot directory provider inside the root directoryscreenshotNameProvider- screenshot file name providerchangeSystemLocale- change the system language, i.e.locales- comma-separated string with locales to run test with.
-
-
Method Detail
-
getUiSafeProxy
final <I extends Any> I getUiSafeProxy(I view)
Return a dynamic proxy for a given view. I must be interface.
- Parameters:
view- proxy target.
-
getUiSafeProxyFromImplementation
final <T extends Any> Object getUiSafeProxyFromImplementation(T view)
Return a dynamic proxy over all interfaces that view implements.
- Parameters:
view- proxy target.
-
getLocaleRule
final LocaleRule getLocaleRule()
-
getStoragePermissionRule
final GrantPermissionRule getStoragePermissionRule()
-
getTestFailRule
final TestFailRule getTestFailRule()
-
getTestCaseName
final String getTestCaseName()
-
getTestAssistantsProvider
final TestAssistantsProviderImpl getTestAssistantsProvider()
-
getAdbServer
AdbServer getAdbServer()
-
getTestLogger
UiTestLogger getTestLogger()
-
getDataProducer
final Function1<Function1<Unit, Unit>, Unit> getDataProducer()
-
getMainSectionEnrichers
final List<MainSectionEnricher<Unit>> getMainSectionEnrichers()
-
-
-
-