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.browser.widget.bottomsheet; | 5 package org.chromium.chrome.browser.widget.bottomsheet; |
6 | 6 |
7 import android.support.test.filters.MediumTest; | 7 import android.support.test.filters.MediumTest; |
8 | 8 |
9 import org.chromium.base.test.util.CallbackHelper; | 9 import org.chromium.base.test.util.CallbackHelper; |
10 import org.chromium.chrome.browser.util.MathUtils; | 10 import org.chromium.chrome.browser.util.MathUtils; |
| 11 import org.chromium.chrome.browser.widget.bottomsheet.BottomSheet.BottomSheetCon
tent; |
11 import org.chromium.chrome.test.BottomSheetTestCaseBase; | 12 import org.chromium.chrome.test.BottomSheetTestCaseBase; |
12 | 13 |
13 import java.util.concurrent.TimeoutException; | 14 import java.util.concurrent.TimeoutException; |
14 | 15 |
15 /** This class tests the functionality of the {@link BottomSheetObserver}. */ | 16 /** This class tests the functionality of the {@link BottomSheetObserver}. */ |
16 public class BottomSheetObserverTest extends BottomSheetTestCaseBase { | 17 public class BottomSheetObserverTest extends BottomSheetTestCaseBase { |
17 /** A handle to the sheet's observer. */ | 18 /** A handle to the sheet's observer. */ |
18 private TestBottomSheetObserver mObserver; | 19 private TestBottomSheetObserver mObserver; |
19 | 20 |
20 /** An observer used to record events that occur with respect to the bottom
sheet. */ | 21 /** An observer used to record events that occur with respect to the bottom
sheet. */ |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 mOpenedCallbackHelper.notifyCalled(); | 55 mOpenedCallbackHelper.notifyCalled(); |
55 } | 56 } |
56 | 57 |
57 @Override | 58 @Override |
58 public void onSheetClosed() { | 59 public void onSheetClosed() { |
59 mClosedCallbackHelper.notifyCalled(); | 60 mClosedCallbackHelper.notifyCalled(); |
60 } | 61 } |
61 | 62 |
62 @Override | 63 @Override |
63 public void onLoadUrl(String url) {} | 64 public void onLoadUrl(String url) {} |
| 65 |
| 66 @Override |
| 67 public void onSheetStateChanged(int newState) {} |
| 68 |
| 69 @Override |
| 70 public void onSheetContentChanged(BottomSheetContent newContent) {} |
64 } | 71 } |
65 | 72 |
66 @Override | 73 @Override |
67 protected void setUp() throws Exception { | 74 protected void setUp() throws Exception { |
68 super.setUp(); | 75 super.setUp(); |
69 | 76 |
70 mObserver = new TestBottomSheetObserver(); | 77 mObserver = new TestBottomSheetObserver(); |
71 mBottomSheet.addObserver(mObserver); | 78 mBottomSheet.addObserver(mObserver); |
72 } | 79 } |
73 | 80 |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 callbackHelper.waitForCallback(callbackCount, 1); | 226 callbackHelper.waitForCallback(callbackCount, 1); |
220 assertEquals(0.5f, mObserver.mLastPeekToHalfValue, MathUtils.EPSILON); | 227 assertEquals(0.5f, mObserver.mLastPeekToHalfValue, MathUtils.EPSILON); |
221 | 228 |
222 // At the half state the event should send 1. | 229 // At the half state the event should send 1. |
223 callbackCount = callbackHelper.getCallCount(); | 230 callbackCount = callbackHelper.getCallCount(); |
224 setSheetOffsetFromBottom(halfHeight); | 231 setSheetOffsetFromBottom(halfHeight); |
225 callbackHelper.waitForCallback(callbackCount, 1); | 232 callbackHelper.waitForCallback(callbackCount, 1); |
226 assertEquals(1f, mObserver.mLastPeekToHalfValue, MathUtils.EPSILON); | 233 assertEquals(1f, mObserver.mLastPeekToHalfValue, MathUtils.EPSILON); |
227 } | 234 } |
228 } | 235 } |
OLD | NEW |