diff options
author | Yorke Lee <yorkelee@google.com> | 2014-10-27 16:46:19 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-10-27 16:46:20 +0000 |
commit | c502ad9957b6e1c32ffa7c4043fe1cda103466be (patch) | |
tree | efa18cd2ad46fe17d32f6129aa378ab6c11d29c7 /tests | |
parent | e5e1483618bbab3d44885c5a5956ff9bc063fff6 (diff) | |
parent | b4aac521569a933a6e7789e9dc25014bdd82d57c (diff) |
Merge "Fix NPEs in ActionBarControllerTest" into lmp-mr1-dev
Diffstat (limited to 'tests')
-rw-r--r-- | tests/src/com/android/dialer/widget/ActionBarControllerTest.java | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/tests/src/com/android/dialer/widget/ActionBarControllerTest.java b/tests/src/com/android/dialer/widget/ActionBarControllerTest.java index cafa747f2..2e388380f 100644 --- a/tests/src/com/android/dialer/widget/ActionBarControllerTest.java +++ b/tests/src/com/android/dialer/widget/ActionBarControllerTest.java @@ -17,25 +17,53 @@ package com.android.dialer.widget; import android.app.ActionBar; +import android.app.Activity; import android.content.Context; +import android.test.ActivityInstrumentationTestCase2; +import android.test.AndroidTestCase; import android.test.InstrumentationTestCase; import android.test.suitebuilder.annotation.SmallTest; +import android.view.View; +import com.android.dialer.DialtactsActivity; import com.android.dialer.widget.ActionBarController.ActivityUi; +import com.android.internal.app.WindowDecorActionBar; @SmallTest -public class ActionBarControllerTest extends InstrumentationTestCase { +public class ActionBarControllerTest extends ActivityInstrumentationTestCase2<DialtactsActivity> { private static final int ACTION_BAR_HEIGHT = 100; private ActionBarController mActionBarController; private SearchEditTextLayout mSearchBox; private MockActivityUi mActivityUi; + private class MockActionBar extends WindowDecorActionBar { + private int mHideOffset = 0; + + public MockActionBar(Activity activity) { + super(activity); + } + + @Override + public void setHideOffset(int offset) { + mHideOffset = offset; + } + + @Override + public int getHideOffset() { + return mHideOffset; + } + } + private class MockActivityUi implements ActivityUi { boolean isInSearchUi; boolean hasSearchQuery; boolean shouldShowActionBar; - int actionBarHideOffset; + private ActionBar mActionBar; + + public MockActivityUi() { + mActionBar = new MockActionBar(getActivity()); + } @Override public boolean isInSearchUi() { @@ -59,7 +87,7 @@ public class ActionBarControllerTest extends InstrumentationTestCase { @Override public ActionBar getActionBar() { - return null; + return mActionBar; } } @@ -83,6 +111,11 @@ public class ActionBarControllerTest extends InstrumentationTestCase { } } + public ActionBarControllerTest() { + super(DialtactsActivity.class); + } + + @Override protected void setUp() { mActivityUi = new MockActivityUi(); |