New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 728297 link

Starred by 1 user

Issue metadata

Status: Available
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 1
Type: Task



Sign in to add a comment

Introduce simple activity to test UI components without needing native or loading tabs

Project Member Reported by tedc...@chromium.org, May 31 2017

Issue description

Currently there is no way to test UI components with Activity dependencies without spinning up an existing Activity within Chrome.

Each of these activities has tons of baggage, is slow, and causes our tests to be unnecessarily flaky and long running.

We should find a way to introduce a new Activity just for testing that is fast to run and where we can attach views and test the Android dependencies w/o all the rest of Chrome running.
 
Components: UI>Browser
Status: Available (was: Untriaged)
My initial attempt was to add a new <activity> in chrome/android/javatests/AndroidManifest.xml.

    <activity android:name="org.chromium.chrome.test.ui.SimpleUiActivity"            
        android:exported="true"/>

I first had issues with writing an ActivityTestRule that would actually trigger the new activity.  Despite setting the class name in getActivityIntent, it would be overwritten in launchActivity.

I could start it manually from the command line via:
    adb shell am start -n org.chromium.chrome.tests/org.chromium.chrome.test.ui.SimpleUiActivity

I had to add a hack to stash the intent and overwrite the class name again in beforeActivityLaunched.

At that point, it complained about the activity being in a different process, so I needed hardcode the process:

    <activity android:name="org.chromium.chrome.test.ui.SimpleUiActivity"
        android:process="{{manifest_package}}"
        android:exported="true"/>

Now the activity was being launched, but it was crashing because it never returned to idle within 45 seconds.  At that point, I gave up.

We might need to add a new <instrumentation> attribute pointing to the test package or something to allow such a crazy thing.
Cc: dfalcant...@chromium.org
Cc: -dfalcant...@chromium.org
Owner: dfalcant...@chromium.org
Status: Started (was: Available)
Cc: jbudorick@chromium.org
+jbudorick
Owner: tedc...@chromium.org
Sending to Ted for triage.
Cc: tedc...@chromium.org
Owner: bauerb@chromium.org
Status: Assigned (was: Started)
I messed around with this some earlier this week -- convincing the OS to load an Activity defined in the test package from within the app package is going to be tricky.

Solutions here will probably involve either:
 - a separate suite
 - merging the test APK and the app APK

Comment 8 by bauerb@chromium.org, Sep 22 2017

I think this might be easier with JUnit 4 tests? At least it should be possible to use an ActivityTestRule that launches a custom SimpleUiActivity.
Owner: ----
Status: Untriaged (was: Assigned)
Bulk edit: Moving back into the untriaged pool, as I'm leaving the project.
Cc: dtrainor@chromium.org yzjr@chromium.org
Cc: yliuyliu@chromium.org
Cc: twelling...@chromium.org
Sorry I might miss something but why add this SimpleUiActivity in test package, as org.chromium.chrome.tests?
Would that be easier if we add it in app package or some isolated application if don't want to affect current chrome app, and launch with ActivityTestRule? 
Labels: -Pri-2 android-fe-triaged Pri-3 Type-Task
Status: Available (was: Untriaged)
@yliuyliu, I'm definitely OK with this being in a different package/application.  We just didn't want this to be part of the shipping Chrome app.

With it being in the same test package, the thinking was that it would create one fewer things to test/be tested on the bots.  It would be part of existing workflows and thus be easier to adopt.  If we found that isn't feasible, I think we could look at moving it elsewhere, but I think the ideal case is that it would work within the existing test packages/APKs.
Owner: yliuyliu@chromium.org
Labels: -Pri-3 Pri-1
Seems this became much easier to implement after test APK and app APK merged into just one apk, ChromePublicTest.apk, with all chrome app libraries and no package difference.
We can simply add one basic activity in javatests/AndroidManifest.xml to skip native and skip Chrome browser initialization to just attach UI components for testing.

Project Member

Comment 20 by bugdroid1@chromium.org, Jan 9

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/b70ea5992740bfa0ddb87c244b47f31d9b8d1dc0

commit b70ea5992740bfa0ddb87c244b47f31d9b8d1dc0
Author: Yun Liu <yliuyliu@google.com>
Date: Wed Jan 09 23:06:26 2019

Add DummyUiActivity for testing UI components without accessing native


Bug: 728297
Change-Id: Iaa573cb32e624544dcf5a1fdbdc9215505596574
Reviewed-on: https://chromium-review.googlesource.com/c/1356593
Commit-Queue: Yun Liu <yliuyliu@google.com>
Reviewed-by: David Trainor <dtrainor@chromium.org>
Cr-Commit-Position: refs/heads/master@{#621357}
[modify] https://crrev.com/b70ea5992740bfa0ddb87c244b47f31d9b8d1dc0/chrome/android/java/src/org/chromium/chrome/browser/download/home/DownloadManagerCoordinatorImpl.java
[modify] https://crrev.com/b70ea5992740bfa0ddb87c244b47f31d9b8d1dc0/chrome/android/java/src/org/chromium/chrome/browser/download/home/list/UiUtils.java
[modify] https://crrev.com/b70ea5992740bfa0ddb87c244b47f31d9b8d1dc0/chrome/android/java/src/org/chromium/chrome/browser/download/home/toolbar/ToolbarCoordinator.java
[modify] https://crrev.com/b70ea5992740bfa0ddb87c244b47f31d9b8d1dc0/chrome/android/java/src/org/chromium/chrome/browser/download/home/toolbar/ToolbarUtils.java
[modify] https://crrev.com/b70ea5992740bfa0ddb87c244b47f31d9b8d1dc0/chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadManagerUi.java
[modify] https://crrev.com/b70ea5992740bfa0ddb87c244b47f31d9b8d1dc0/chrome/android/java_sources.gni
[modify] https://crrev.com/b70ea5992740bfa0ddb87c244b47f31d9b8d1dc0/chrome/android/javatests/AndroidManifest.xml
[add] https://crrev.com/b70ea5992740bfa0ddb87c244b47f31d9b8d1dc0/chrome/android/javatests/src/org/chromium/chrome/browser/download/home/DownloadActivityV2Test.java
[add] https://crrev.com/b70ea5992740bfa0ddb87c244b47f31d9b8d1dc0/chrome/android/javatests/src/org/chromium/chrome/test/ui/DummyUiActivity.java

Sign in to add a comment