OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.chrome.browser.compositor.overlays.strip; | 5 package org.chromium.chrome.browser.compositor.overlays.strip; |
6 | 6 |
7 import static org.junit.Assert.assertEquals; | 7 import static org.junit.Assert.assertEquals; |
8 import static org.mockito.ArgumentMatchers.any; | 8 import static org.mockito.ArgumentMatchers.any; |
9 import static org.mockito.ArgumentMatchers.anyBoolean; | 9 import static org.mockito.ArgumentMatchers.anyBoolean; |
10 import static org.mockito.ArgumentMatchers.anyFloat; | 10 import static org.mockito.ArgumentMatchers.anyFloat; |
11 import static org.mockito.ArgumentMatchers.anyInt; | 11 import static org.mockito.ArgumentMatchers.anyInt; |
12 import static org.mockito.ArgumentMatchers.isNull; | 12 import static org.mockito.ArgumentMatchers.isNull; |
13 import static org.mockito.Mockito.mock; | 13 import static org.mockito.Mockito.mock; |
14 import static org.mockito.Mockito.when; | 14 import static org.mockito.Mockito.when; |
15 | 15 |
16 import android.content.Context; | 16 import android.content.Context; |
17 import android.content.res.Configuration; | 17 import android.content.res.Configuration; |
18 import android.content.res.Resources; | 18 import android.content.res.Resources; |
19 import android.content.res.TypedArray; | 19 import android.content.res.TypedArray; |
20 import android.text.TextUtils; | 20 import android.text.TextUtils; |
21 import android.util.AttributeSet; | 21 import android.util.AttributeSet; |
22 import android.util.DisplayMetrics; | 22 import android.util.DisplayMetrics; |
23 | 23 |
| 24 import org.junit.Before; |
| 25 import org.junit.Test; |
| 26 import org.junit.runner.RunWith; |
| 27 import org.mockito.Mock; |
| 28 import org.mockito.MockitoAnnotations; |
| 29 import org.robolectric.RuntimeEnvironment; |
| 30 import org.robolectric.annotation.Config; |
| 31 |
| 32 import org.chromium.base.ContextUtils; |
24 import org.chromium.base.test.util.Feature; | 33 import org.chromium.base.test.util.Feature; |
25 import org.chromium.chrome.R; | 34 import org.chromium.chrome.R; |
26 import org.chromium.chrome.browser.compositor.layouts.LayoutRenderHost; | 35 import org.chromium.chrome.browser.compositor.layouts.LayoutRenderHost; |
27 import org.chromium.chrome.browser.compositor.layouts.LayoutUpdateHost; | 36 import org.chromium.chrome.browser.compositor.layouts.LayoutUpdateHost; |
28 import org.chromium.chrome.browser.compositor.layouts.components.VirtualView; | 37 import org.chromium.chrome.browser.compositor.layouts.components.VirtualView; |
29 import org.chromium.chrome.browser.tab.Tab; | 38 import org.chromium.chrome.browser.tab.Tab; |
30 import org.chromium.chrome.browser.tabmodel.EmptyTabModel; | 39 import org.chromium.chrome.browser.tabmodel.EmptyTabModel; |
31 import org.chromium.testing.local.LocalRobolectricTestRunner; | 40 import org.chromium.testing.local.LocalRobolectricTestRunner; |
32 import org.chromium.ui.base.LocalizationUtils; | 41 import org.chromium.ui.base.LocalizationUtils; |
33 import org.junit.Before; | |
34 import org.junit.Test; | |
35 import org.junit.runner.RunWith; | |
36 import org.mockito.Mock; | |
37 import org.mockito.MockitoAnnotations; | |
38 import org.robolectric.annotation.Config; | |
39 | 42 |
40 import java.util.ArrayList; | 43 import java.util.ArrayList; |
41 import java.util.List; | 44 import java.util.List; |
42 | 45 |
43 /** Tests for {@link StripLayoutHelper}. */ | 46 /** Tests for {@link StripLayoutHelper}. */ |
44 @RunWith(LocalRobolectricTestRunner.class) | 47 @RunWith(LocalRobolectricTestRunner.class) |
45 @Config(manifest = Config.NONE) | 48 @Config(manifest = Config.NONE, sdk = 21) |
46 public class StripLayoutHelperTest { | 49 public class StripLayoutHelperTest { |
47 @Mock private Context mContext; | 50 @Mock private Context mContext; |
48 @Mock private Resources mResources; | 51 @Mock private Resources mResources; |
49 @Mock private LayoutUpdateHost mUpdateHost; | 52 @Mock private LayoutUpdateHost mUpdateHost; |
50 @Mock private LayoutRenderHost mRenderHost; | 53 @Mock private LayoutRenderHost mRenderHost; |
51 private TestTabModel mModel = new TestTabModel(); | 54 private TestTabModel mModel = new TestTabModel(); |
52 private StripLayoutHelper mStripLayoutHelper; | 55 private StripLayoutHelper mStripLayoutHelper; |
53 private boolean mIncognito; | 56 private boolean mIncognito; |
54 private static final String[] TEST_TAB_TITLES = {"Tab 1", "Tab 2", "Tab 3",
"", null}; | 57 private static final String[] TEST_TAB_TITLES = {"Tab 1", "Tab 2", "Tab 3",
"", null}; |
55 private static final String CLOSE_TAB = "Close tab test string"; | 58 private static final String CLOSE_TAB = "Close tab test string"; |
56 private static final String NEW_TAB = "New tab test string"; | 59 private static final String NEW_TAB = "New tab test string"; |
57 private static final String NEW_INCOGNITO_TAB = "New incognito tab test stri
ng"; | 60 private static final String NEW_INCOGNITO_TAB = "New incognito tab test stri
ng"; |
58 private static final String IDENTIFIER = "Tab"; | 61 private static final String IDENTIFIER = "Tab"; |
59 private static final String IDENTIFIER_SELECTED = "Selected Tab"; | 62 private static final String IDENTIFIER_SELECTED = "Selected Tab"; |
60 private static final String INCOGNITO_IDENTIFIER = "Incognito Tab"; | 63 private static final String INCOGNITO_IDENTIFIER = "Incognito Tab"; |
61 private static final String INCOGNITO_IDENTIFIER_SELECTED = "Selected Incogn
ito Tab"; | 64 private static final String INCOGNITO_IDENTIFIER_SELECTED = "Selected Incogn
ito Tab"; |
62 | 65 |
63 /** Reset the environment before each test. */ | 66 /** Reset the environment before each test. */ |
64 @Before | 67 @Before |
65 public void beforeTest() { | 68 public void beforeTest() { |
| 69 ContextUtils.initApplicationContextForTests(RuntimeEnvironment.applicati
on); |
| 70 |
66 MockitoAnnotations.initMocks(this); | 71 MockitoAnnotations.initMocks(this); |
67 when(mContext.getResources()).thenReturn(mResources); | 72 when(mContext.getResources()).thenReturn(mResources); |
68 when(mResources.getString(R.string.accessibility_tabstrip_btn_close_tab)
).thenReturn( | 73 when(mResources.getString(R.string.accessibility_tabstrip_btn_close_tab)
).thenReturn( |
69 CLOSE_TAB); | 74 CLOSE_TAB); |
70 when(mResources.getString(R.string.accessibility_toolbar_btn_new_tab)).t
henReturn(NEW_TAB); | 75 when(mResources.getString(R.string.accessibility_toolbar_btn_new_tab)).t
henReturn(NEW_TAB); |
71 when(mResources.getString(R.string.accessibility_toolbar_btn_new_incogni
to_tab)) | 76 when(mResources.getString(R.string.accessibility_toolbar_btn_new_incogni
to_tab)) |
72 .thenReturn(NEW_INCOGNITO_TAB); | 77 .thenReturn(NEW_INCOGNITO_TAB); |
73 when(mResources.getString(R.string.accessibility_tabstrip_identifier)) | 78 when(mResources.getString(R.string.accessibility_tabstrip_identifier)) |
74 .thenReturn(IDENTIFIER); | 79 .thenReturn(IDENTIFIER); |
75 when(mResources.getString(R.string.accessibility_tabstrip_identifier_sel
ected)) | 80 when(mResources.getString(R.string.accessibility_tabstrip_identifier_sel
ected)) |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 @Override | 241 @Override |
237 public int index() { | 242 public int index() { |
238 return mIndex; | 243 return mIndex; |
239 } | 244 } |
240 | 245 |
241 public void setIndex(int index) { | 246 public void setIndex(int index) { |
242 mIndex = index; | 247 mIndex = index; |
243 } | 248 } |
244 } | 249 } |
245 } | 250 } |
OLD | NEW |