Closed Bug 914377 Opened 11 years ago Closed 11 years ago

Intermittent testShareLink | Exception caught - junit.framework.AssertionFailedError: View is null and can therefore not be clicked!

Categories

(Firefox for Android Graveyard :: General, defect)

ARM
Android
defect
Not set
normal

Tracking

(firefox25 unaffected, firefox26 fixed, firefox27 fixed, firefox-esr24 unaffected)

RESOLVED FIXED
Firefox 27
Tracking Status
firefox25 --- unaffected
firefox26 --- fixed
firefox27 --- fixed
firefox-esr24 --- unaffected

People

(Reporter: RyanVM, Assigned: liuche)

Details

(Keywords: assertion, intermittent-failure)

Attachments

(3 files, 1 obsolete file)

https://tbpl.mozilla.org/php/getParsedLog.php?id=27593112&tree=Fx-Team

Android Tegra 250 fx-team opt test robocop-2 on 2013-09-09 12:47:15 PDT for push bbddba8cc6e6
slave: tegra-097

INFO | automation.py | Application pid: 0
0 INFO SimpleTest START
1 INFO TEST-START | testShareLink
EventExpecter: no longer listening for Gecko:Ready
2 INFO TEST-PASS | testShareLink | waiting for urlbar text to gain focus - urlbar text gained focus
3 INFO TEST-PASS | testShareLink | URL typed properly - http://mochi.test:8888/tests/robocop/robocop_big_link.html should equal http://mochi.test:8888/tests/robocop/robocop_big_link.html
EventExpecter: no longer listening for DOMContentLoaded
4 INFO TEST-PASS | testShareLink | Page title is correct - Big Link should equal Big Link
waitForText timeout on ^Share$
5 INFO TEST-PASS | testShareLink | Got the displayed share options? - Got the share options view
6 INFO TEST-PASS | testShareLink | Share option found - Messaging
7 INFO TEST-PASS | testShareLink | Share option found - Bluetooth
8 INFO TEST-PASS | testShareLink | Share option found - Firefox Sync
9 INFO TEST-PASS | testShareLink | Got the displayed share options? - Got the share options view
10 INFO TEST-PASS | testShareLink | Share option for urlbar found - Messaging
11 INFO TEST-PASS | testShareLink | Share option for urlbar found - Bluetooth
12 INFO TEST-PASS | testShareLink | Share option for urlbar found - Firefox Sync
13 INFO TEST-PASS | testShareLink | Got the displayed share options? - Got the share options view
14 INFO TEST-PASS | testShareLink | Share option for Link item found - Messaging
15 INFO TEST-PASS | testShareLink | Share option for Link item found - Bluetooth
16 INFO TEST-PASS | testShareLink | Share option for Link item found - Firefox Sync
17 INFO TEST-PASS | testShareLink | waiting for urlbar text to gain focus - urlbar text gained focus
18 INFO TEST-PASS | testShareLink | Checking that the correct tab is displayed - The BOOKMARKS tab is displayed
19 INFO TEST-PASS | testShareLink | list is properly loaded - true should equal true
Exception caught during test!
junit.framework.AssertionFailedError: View is null and can therefore not be clicked!
	at junit.framework.Assert.fail(Assert.java:47)
	at junit.framework.Assert.assertTrue(Assert.java:20)
	at com.jayway.android.robotium.solo.Clicker.clickOnScreen(Clicker.java:167)
	at com.jayway.android.robotium.solo.Solo.clickLongOnView(Solo.java:974)
	at org.mozilla.fennec.tests.testShareLink.testShareLink(testShareLink.java:86)
	at java.lang.reflect.Method.invokeNative(Native Method)
	at java.lang.reflect.Method.invoke(Method.java:521)
	at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:204)
	at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:194)
	at android.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTestCase2.java:186)
	at org.mozilla.fennec.tests.BaseTest.runTest(BaseTest.java:161)
	at junit.framework.TestCase.runBare(TestCase.java:127)
	at junit.framework.TestResult$1.protect(TestResult.java:106)
	at junit.framework.TestResult.runProtected(TestResult.java:124)
	at junit.framework.TestResult.run(TestResult.java:109)
	at junit.framework.TestCase.run(TestCase.java:118)
	at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
	at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
	at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:520)
	at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1447)
20 INFO TEST-UNEXPECTED-FAIL | testShareLink | Exception caught - junit.framework.AssertionFailedError: View is null and can therefore not be clicked!
21 INFO TEST-END | testShareLink | finished in 75115ms
22 INFO TEST-START | Shutdown
23 INFO Passed: 18
24 INFO Failed: 1
25 INFO Todo: 0
26 INFO SimpleTest FINISHED
It looks like the failure is happening here:
http://mxr.mozilla.org/mozilla-central/source/mobile/android/base/tests/testShareLink.java.in#77

Maybe we need to do something to wait for the bookmarks list to load? I would suggest this problem has to do with the fact that we got rid of thumbnails on the bookmarks page, but it looks like this failure popped up before we landed the new-new-about-home.
The intermittents are happening because for bookmarks on tablets, we have an extra header that gets loaded before the list items are loaded, so both the Adapter and ListView are non-null, and we try to get items from the Bookmarks list.
Assignee: nobody → liuche
Status: NEW → ASSIGNED
Attachment #810698 - Flags: review?(gbrown)
Attached image p0.jpg
Bookmarks listitem(0) appears to be empty (?) 

|mSolo.clickLongOnView(bookmarksItem);| may fail ...

if |bookmarksList.getHeaderViewsCount() = 0| then
   View bookmarksItem = bookmarksList.getChildAt(0) may here == null ?
      and |mSolo.clickLongOnView(bookmarksItem);| may fail ... ?

Maybe some timing thing in BookmarksListAdapter.java displaying the unusual bookmarksList ...
Comment on attachment 810698 [details] [diff] [review]
Patch: check for non-empty ListView

Review of attachment 810698 [details] [diff] [review]:
-----------------------------------------------------------------

I like this change and see nothing wrong with it. There is still one instance of this failure in the try run as noted in Comment 59. Maybe testShareLink should waitForListToLoad(listView, 3) instead of waitForNonEmptyListToLoad()? Or maybe a try run with more logging would tell us more about what is happening, like what does getHeaderViewsCount() return just before the failure?
Attachment #810698 - Flags: review?(gbrown) → review+
:liuche -- This test is failing frequently. Do you think your patch will reduce the failures? If so, please land it soon, even if it is not perfect (does not eliminate all the failures).
Flags: needinfo?(liuche)
I'm sure this patch would help, so let me land it. It's bit-rotted a little, so let me get a green try run and then will land.
Flags: needinfo?(liuche)
https://hg.mozilla.org/mozilla-central/rev/ae48a373ea5c
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 27
reopen - seems its still happening see https://tbpl.mozilla.org/php/getParsedLog.php?id=29082131&tree=Mozilla-Inbound
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Yes, that was expected based on comment 157. Liuche, in the future, you can put [leave open] on the whiteboard to avoid the bug being closed when it lands m-c. :-)
Thanks Ryan, will do!
Trying to diagnose this here: https://tbpl.mozilla.org/?tree=Try&rev=c8ec2ef7c844

If this doesn't point to a solution, let's disable this test.
We hit this failure and successfully recovered at least a couple of times:

https://tbpl.mozilla.org/php/getParsedLog.php?id=29521719&tree=Try&full=1
https://tbpl.mozilla.org/php/getParsedLog.php?id=29521740&tree=Try&full=1

17:53:15     INFO -  17 INFO TEST-PASS | testShareLink | Share option for Link item found - Firefox Sync
17:53:15     INFO -  18 INFO TEST-PASS | testShareLink | waiting for urlbar text to gain focus - urlbar text gained focus
17:53:15     INFO -  19 INFO TEST-PASS | testShareLink | list is properly loaded - true should equal true
17:53:15     INFO -  got null child at index 1
17:53:15     INFO -  after pause, got index 1 and item org.mozilla.gecko.home.TwoLinePageRow@413690b0
17:53:15     INFO -  20 INFO TEST-PASS | testShareLink | Got the displayed share options? - Got the share options view
17:53:15     INFO -  21 INFO TEST-PASS | testShareLink | Share option for bookmarks item found - Messaging
Comment on attachment 820760 [details] [diff] [review]
if bookmark list child is null, retry to avoid failure

Review of attachment 820760 [details] [diff] [review]:
-----------------------------------------------------------------

Looks good to me, but there seem to be failures on r4. Is that related?

::: mobile/android/base/tests/testShareLink.java.in
@@ +13,5 @@
>  import android.widget.AbsListView;
>  import android.widget.GridView;
>  import android.widget.ListView;
>  import android.widget.TextView;
> +import com.jayway.android.robotium.solo.Condition;

In AboutHomeTest and BaseTest, we have these imports in a separate section - consider moving this for consistency.

@@ +77,5 @@
>  
> +        int headerViewsCount = bookmarksList.getHeaderViewsCount();
> +        View bookmarksItem = bookmarksList.getChildAt(headerViewsCount);
> +        if (bookmarksItem == null) {
> +            mAsserter.dumpLog("got null child at index "+headerViewsCount);

Nit: spaces around "+" operator.
Attachment #820760 - Flags: review?(liuche) → review-
Nits addressed. 

The rc4 failure is unrelated: My try push included a modification -- not in this patch -- to robocop.ini, to run this test repeatedly. Unfortunately, the test harness has a bug when "chunking" a set of tests that have duplicates...that caused the rc4 failure.
Attachment #820760 - Attachment is obsolete: true
Attachment #821338 - Flags: review?(liuche)
Comment on attachment 821338 [details] [diff] [review]
if bookmark list child is null, retry to avoid failure

Review of attachment 821338 [details] [diff] [review]:
-----------------------------------------------------------------

Great, glad that's not related!

::: mobile/android/base/tests/testShareLink.java.in
@@ +77,5 @@
>  
> +        int headerViewsCount = bookmarksList.getHeaderViewsCount();
> +        View bookmarksItem = bookmarksList.getChildAt(headerViewsCount);
> +        if (bookmarksItem == null) {
> +            mAsserter.dumpLog("got null child at index " + headerViewsCount);

One last thing - do you think it would be useful to add a log statement here saying that we're going to wait for MAX_WAIT_MS for the view?
Attachment #821338 - Flags: review?(liuche) → review+
https://hg.mozilla.org/mozilla-central/rev/3b601d64426b
Status: REOPENED → RESOLVED
Closed: 11 years ago11 years ago
Resolution: --- → FIXED
fyi - I've a related patch waiting review - affects all consumers of AboutHomeTest.java.in methods getDisplayedBookmark() and findListViewWithTag() ... see bug 925264 ... root cause and graceful correction to "View is null" problem ... 

pardon me jumping in if this is actually ot related
Thanks. 

It looks like the same problem: testShareLink was failing when it retrieved the bookmarks list with findListViewWithTag() and then tried to click on an item without checking/waiting to see if the item view was non-null. Now it uses waitForCondition to wait for a non-null view if necessary.
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: