| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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.test; | 5 package org.chromium.chrome.test; |
| 6 | 6 |
| 7 import static org.chromium.chrome.test.util.ChromeRestriction.RESTRICTION_TYPE_P
HONE; | 7 import static org.chromium.chrome.test.util.ChromeRestriction.RESTRICTION_TYPE_P
HONE; |
| 8 | 8 |
| 9 import android.support.v7.widget.RecyclerView; | 9 import android.support.v7.widget.RecyclerView; |
| 10 | 10 |
| 11 import org.chromium.base.ThreadUtils; | 11 import org.chromium.base.ThreadUtils; |
| 12 import org.chromium.base.test.util.CommandLineFlags; | 12 import org.chromium.base.test.util.CommandLineFlags; |
| 13 import org.chromium.base.test.util.Restriction; | 13 import org.chromium.base.test.util.Restriction; |
| 14 import org.chromium.chrome.R; |
| 14 import org.chromium.chrome.browser.preferences.ChromePreferenceManager; | 15 import org.chromium.chrome.browser.preferences.ChromePreferenceManager; |
| 15 import org.chromium.chrome.browser.widget.bottomsheet.BottomSheet; | 16 import org.chromium.chrome.browser.widget.bottomsheet.BottomSheet; |
| 16 import org.chromium.chrome.browser.widget.bottomsheet.BottomSheet.BottomSheetCon
tent; | 17 import org.chromium.chrome.browser.widget.bottomsheet.BottomSheet.BottomSheetCon
tent; |
| 17 import org.chromium.chrome.browser.widget.bottomsheet.BottomSheetContentControll
er; | 18 import org.chromium.chrome.browser.widget.bottomsheet.BottomSheetContentControll
er; |
| 18 import org.chromium.chrome.test.util.browser.RecyclerViewTestUtils; | 19 import org.chromium.chrome.test.util.browser.RecyclerViewTestUtils; |
| 19 | 20 |
| 20 /** | 21 /** |
| 21 * Base class for instrumentation tests using the bottom sheet. | 22 * Base class for instrumentation tests using the bottom sheet. |
| 22 */ | 23 */ |
| 23 @CommandLineFlags.Add({"enable-features=ChromeHome"}) | 24 @CommandLineFlags.Add({"enable-features=ChromeHome"}) |
| (...skipping 20 matching lines...) Expand all Loading... |
| 44 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 45 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
| 45 @Override | 46 @Override |
| 46 public void run() { | 47 public void run() { |
| 47 getActivity().getBottomSheet().setSheetState( | 48 getActivity().getBottomSheet().setSheetState( |
| 48 BottomSheet.SHEET_STATE_FULL, /* animate = */ false); | 49 BottomSheet.SHEET_STATE_FULL, /* animate = */ false); |
| 49 } | 50 } |
| 50 }); | 51 }); |
| 51 // The default BottomSheetContent is SuggestionsBottomSheetContent, whos
e content view is a | 52 // The default BottomSheetContent is SuggestionsBottomSheetContent, whos
e content view is a |
| 52 // RecyclerView. | 53 // RecyclerView. |
| 53 RecyclerViewTestUtils.waitForStableRecyclerView( | 54 RecyclerViewTestUtils.waitForStableRecyclerView( |
| 54 ((RecyclerView) getBottomSheetContent().getContentView())); | 55 ((RecyclerView) getBottomSheetContent().getContentView().findVie
wById( |
| 56 R.id.recycler_view))); |
| 55 | 57 |
| 56 mBottomSheet = getActivity().getBottomSheet(); | 58 mBottomSheet = getActivity().getBottomSheet(); |
| 57 mBottomSheetContentController = getActivity().getBottomSheetContentContr
oller(); | 59 mBottomSheetContentController = getActivity().getBottomSheetContentContr
oller(); |
| 58 } | 60 } |
| 59 | 61 |
| 60 @Override | 62 @Override |
| 61 public void startMainActivity() throws InterruptedException { | 63 public void startMainActivity() throws InterruptedException { |
| 62 startMainActivityOnBlankPage(); | 64 startMainActivityOnBlankPage(); |
| 63 } | 65 } |
| 64 | 66 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 */ | 107 */ |
| 106 protected void selectBottomSheetContent(final int itemId) { | 108 protected void selectBottomSheetContent(final int itemId) { |
| 107 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 109 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
| 108 @Override | 110 @Override |
| 109 public void run() { | 111 public void run() { |
| 110 mBottomSheetContentController.selectItemForTests(itemId); | 112 mBottomSheetContentController.selectItemForTests(itemId); |
| 111 } | 113 } |
| 112 }); | 114 }); |
| 113 } | 115 } |
| 114 } | 116 } |
| OLD | NEW |