Robert Snoeberger | b300a4e | 2019-02-13 20:13:53 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2019 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | package com.android.keyguard.clock; |
| 17 | |
| 18 | import static com.google.common.truth.Truth.assertThat; |
| 19 | |
Robert Snoeberger | 71e5079 | 2019-02-15 15:48:01 -0500 | [diff] [blame] | 20 | import static org.mockito.ArgumentMatchers.any; |
Robert Snoeberger | 372e13f | 2019-04-08 17:07:14 -0400 | [diff] [blame] | 21 | import static org.mockito.ArgumentMatchers.anyInt; |
Robert Snoeberger | d8445ea | 2019-03-27 10:41:23 -0400 | [diff] [blame] | 22 | import static org.mockito.Mockito.reset; |
shawnlin | f443938 | 2019-05-23 20:44:49 +0800 | [diff] [blame] | 23 | import static org.mockito.Mockito.spy; |
Robert Snoeberger | d8445ea | 2019-03-27 10:41:23 -0400 | [diff] [blame] | 24 | import static org.mockito.Mockito.verify; |
Robert Snoeberger | 71e5079 | 2019-02-15 15:48:01 -0500 | [diff] [blame] | 25 | import static org.mockito.Mockito.when; |
| 26 | |
| 27 | import android.content.ContentResolver; |
| 28 | import android.database.ContentObserver; |
Robert Snoeberger | 372e13f | 2019-04-08 17:07:14 -0400 | [diff] [blame] | 29 | import android.net.Uri; |
shawnlin | f443938 | 2019-05-23 20:44:49 +0800 | [diff] [blame] | 30 | import android.provider.DeviceConfig; |
Robert Snoeberger | b300a4e | 2019-02-13 20:13:53 +0000 | [diff] [blame] | 31 | import android.test.suitebuilder.annotation.SmallTest; |
| 32 | import android.testing.AndroidTestingRunner; |
Robert Snoeberger | b300a4e | 2019-02-13 20:13:53 +0000 | [diff] [blame] | 33 | import android.testing.TestableLooper.RunWithLooper; |
Robert Snoeberger | 71e5079 | 2019-02-15 15:48:01 -0500 | [diff] [blame] | 34 | import android.view.LayoutInflater; |
Robert Snoeberger | b300a4e | 2019-02-13 20:13:53 +0000 | [diff] [blame] | 35 | |
Robert Snoeberger | be2a188 | 2019-04-10 13:48:02 -0400 | [diff] [blame] | 36 | import androidx.lifecycle.MutableLiveData; |
| 37 | |
Robert Snoeberger | b300a4e | 2019-02-13 20:13:53 +0000 | [diff] [blame] | 38 | import com.android.systemui.SysuiTestCase; |
Robert Snoeberger | 71e5079 | 2019-02-15 15:48:01 -0500 | [diff] [blame] | 39 | import com.android.systemui.colorextraction.SysuiColorExtractor; |
Robert Snoeberger | b300a4e | 2019-02-13 20:13:53 +0000 | [diff] [blame] | 40 | import com.android.systemui.dock.DockManager; |
| 41 | import com.android.systemui.dock.DockManagerFake; |
Robert Snoeberger | d8445ea | 2019-03-27 10:41:23 -0400 | [diff] [blame] | 42 | import com.android.systemui.plugins.ClockPlugin; |
Robert Snoeberger | be2a188 | 2019-04-10 13:48:02 -0400 | [diff] [blame] | 43 | import com.android.systemui.settings.CurrentUserObservable; |
Robert Snoeberger | 9ad03f4 | 2019-02-28 14:47:49 -0500 | [diff] [blame] | 44 | import com.android.systemui.shared.plugins.PluginManager; |
Robert Snoeberger | 71e5079 | 2019-02-15 15:48:01 -0500 | [diff] [blame] | 45 | import com.android.systemui.util.InjectionInflationController; |
Robert Snoeberger | b300a4e | 2019-02-13 20:13:53 +0000 | [diff] [blame] | 46 | |
| 47 | import org.junit.After; |
| 48 | import org.junit.Before; |
| 49 | import org.junit.Test; |
| 50 | import org.junit.runner.RunWith; |
Robert Snoeberger | d8445ea | 2019-03-27 10:41:23 -0400 | [diff] [blame] | 51 | import org.mockito.ArgumentCaptor; |
Robert Snoeberger | b300a4e | 2019-02-13 20:13:53 +0000 | [diff] [blame] | 52 | import org.mockito.Mock; |
| 53 | import org.mockito.MockitoAnnotations; |
| 54 | |
shawnlin | f443938 | 2019-05-23 20:44:49 +0800 | [diff] [blame] | 55 | import java.util.List; |
| 56 | |
Robert Snoeberger | b300a4e | 2019-02-13 20:13:53 +0000 | [diff] [blame] | 57 | @SmallTest |
| 58 | @RunWith(AndroidTestingRunner.class) |
Robert Snoeberger | be2a188 | 2019-04-10 13:48:02 -0400 | [diff] [blame] | 59 | // Need to run tests on main looper because LiveData operations such as setData, observe, |
| 60 | // removeObserver cannot be invoked on a background thread. |
| 61 | @RunWithLooper(setAsMainLooper = true) |
Robert Snoeberger | b300a4e | 2019-02-13 20:13:53 +0000 | [diff] [blame] | 62 | public final class ClockManagerTest extends SysuiTestCase { |
| 63 | |
Robert Snoeberger | 71e5079 | 2019-02-15 15:48:01 -0500 | [diff] [blame] | 64 | private static final String BUBBLE_CLOCK = BubbleClockController.class.getName(); |
| 65 | private static final Class<?> BUBBLE_CLOCK_CLASS = BubbleClockController.class; |
Robert Snoeberger | be2a188 | 2019-04-10 13:48:02 -0400 | [diff] [blame] | 66 | private static final int MAIN_USER_ID = 0; |
| 67 | private static final int SECONDARY_USER_ID = 11; |
Robert Snoeberger | 372e13f | 2019-04-08 17:07:14 -0400 | [diff] [blame] | 68 | private static final Uri SETTINGS_URI = null; |
Robert Snoeberger | 71e5079 | 2019-02-15 15:48:01 -0500 | [diff] [blame] | 69 | |
shawnlin | f443938 | 2019-05-23 20:44:49 +0800 | [diff] [blame] | 70 | ClockManager mClockManager; |
Robert Snoeberger | 71e5079 | 2019-02-15 15:48:01 -0500 | [diff] [blame] | 71 | private ContentObserver mContentObserver; |
Robert Snoeberger | b300a4e | 2019-02-13 20:13:53 +0000 | [diff] [blame] | 72 | private DockManagerFake mFakeDockManager; |
Robert Snoeberger | be2a188 | 2019-04-10 13:48:02 -0400 | [diff] [blame] | 73 | private MutableLiveData<Integer> mCurrentUser; |
Robert Snoeberger | 71e5079 | 2019-02-15 15:48:01 -0500 | [diff] [blame] | 74 | @Mock InjectionInflationController mMockInjectionInflationController; |
Robert Snoeberger | 9ad03f4 | 2019-02-28 14:47:49 -0500 | [diff] [blame] | 75 | @Mock PluginManager mMockPluginManager; |
Robert Snoeberger | 71e5079 | 2019-02-15 15:48:01 -0500 | [diff] [blame] | 76 | @Mock SysuiColorExtractor mMockColorExtractor; |
| 77 | @Mock ContentResolver mMockContentResolver; |
Robert Snoeberger | be2a188 | 2019-04-10 13:48:02 -0400 | [diff] [blame] | 78 | @Mock CurrentUserObservable mMockCurrentUserObserable; |
Robert Snoeberger | 71e5079 | 2019-02-15 15:48:01 -0500 | [diff] [blame] | 79 | @Mock SettingsWrapper mMockSettingsWrapper; |
Robert Snoeberger | d8445ea | 2019-03-27 10:41:23 -0400 | [diff] [blame] | 80 | @Mock ClockManager.ClockChangedListener mMockListener1; |
| 81 | @Mock ClockManager.ClockChangedListener mMockListener2; |
Robert Snoeberger | b300a4e | 2019-02-13 20:13:53 +0000 | [diff] [blame] | 82 | |
| 83 | @Before |
| 84 | public void setUp() { |
| 85 | MockitoAnnotations.initMocks(this); |
Robert Snoeberger | 71e5079 | 2019-02-15 15:48:01 -0500 | [diff] [blame] | 86 | |
| 87 | LayoutInflater inflater = LayoutInflater.from(getContext()); |
| 88 | when(mMockInjectionInflationController.injectable(any())).thenReturn(inflater); |
| 89 | |
Robert Snoeberger | b300a4e | 2019-02-13 20:13:53 +0000 | [diff] [blame] | 90 | mFakeDockManager = new DockManagerFake(); |
Robert Snoeberger | 3f4650c | 2019-03-25 14:41:42 -0400 | [diff] [blame] | 91 | |
Robert Snoeberger | be2a188 | 2019-04-10 13:48:02 -0400 | [diff] [blame] | 92 | mCurrentUser = new MutableLiveData<>(); |
| 93 | mCurrentUser.setValue(MAIN_USER_ID); |
| 94 | when(mMockCurrentUserObserable.getCurrentUser()).thenReturn(mCurrentUser); |
| 95 | |
Robert Snoeberger | 71e5079 | 2019-02-15 15:48:01 -0500 | [diff] [blame] | 96 | mClockManager = new ClockManager(getContext(), mMockInjectionInflationController, |
Robert Snoeberger | 3f4650c | 2019-03-25 14:41:42 -0400 | [diff] [blame] | 97 | mMockPluginManager, mMockColorExtractor, mMockContentResolver, |
Lucas Dupin | d93e95f | 2019-05-01 00:49:35 +0000 | [diff] [blame] | 98 | mMockCurrentUserObserable, mMockSettingsWrapper, mFakeDockManager); |
Robert Snoeberger | 71e5079 | 2019-02-15 15:48:01 -0500 | [diff] [blame] | 99 | |
Robert Snoeberger | d8445ea | 2019-03-27 10:41:23 -0400 | [diff] [blame] | 100 | mClockManager.addOnClockChangedListener(mMockListener1); |
| 101 | mClockManager.addOnClockChangedListener(mMockListener2); |
| 102 | reset(mMockListener1, mMockListener2); |
| 103 | |
Robert Snoeberger | 71e5079 | 2019-02-15 15:48:01 -0500 | [diff] [blame] | 104 | mContentObserver = mClockManager.getContentObserver(); |
Robert Snoeberger | b300a4e | 2019-02-13 20:13:53 +0000 | [diff] [blame] | 105 | } |
| 106 | |
| 107 | @After |
| 108 | public void tearDown() { |
Robert Snoeberger | d8445ea | 2019-03-27 10:41:23 -0400 | [diff] [blame] | 109 | mClockManager.removeOnClockChangedListener(mMockListener1); |
| 110 | mClockManager.removeOnClockChangedListener(mMockListener2); |
Robert Snoeberger | b300a4e | 2019-02-13 20:13:53 +0000 | [diff] [blame] | 111 | } |
| 112 | |
| 113 | @Test |
| 114 | public void dockEvent() { |
| 115 | mFakeDockManager.setDockEvent(DockManager.STATE_DOCKED); |
| 116 | assertThat(mClockManager.isDocked()).isTrue(); |
| 117 | } |
| 118 | |
| 119 | @Test |
| 120 | public void undockEvent() { |
| 121 | mFakeDockManager.setDockEvent(DockManager.STATE_NONE); |
| 122 | assertThat(mClockManager.isDocked()).isFalse(); |
| 123 | } |
Robert Snoeberger | 71e5079 | 2019-02-15 15:48:01 -0500 | [diff] [blame] | 124 | |
| 125 | @Test |
| 126 | public void getCurrentClock_default() { |
| 127 | // GIVEN that settings doesn't contain any values |
Robert Snoeberger | 372e13f | 2019-04-08 17:07:14 -0400 | [diff] [blame] | 128 | when(mMockSettingsWrapper.getLockScreenCustomClockFace(anyInt())).thenReturn(null); |
| 129 | when(mMockSettingsWrapper.getDockedClockFace(anyInt())).thenReturn(null); |
Robert Snoeberger | 71e5079 | 2019-02-15 15:48:01 -0500 | [diff] [blame] | 130 | // WHEN settings change event is fired |
Robert Snoeberger | be2a188 | 2019-04-10 13:48:02 -0400 | [diff] [blame] | 131 | mContentObserver.onChange(false, SETTINGS_URI, MAIN_USER_ID); |
Robert Snoeberger | 71e5079 | 2019-02-15 15:48:01 -0500 | [diff] [blame] | 132 | // THEN the result is null, indicated the default clock face should be used. |
| 133 | assertThat(mClockManager.getCurrentClock()).isNull(); |
| 134 | } |
| 135 | |
| 136 | @Test |
| 137 | public void getCurrentClock_customClock() { |
| 138 | // GIVEN that settings is set to the bubble clock face |
Robert Snoeberger | 372e13f | 2019-04-08 17:07:14 -0400 | [diff] [blame] | 139 | when(mMockSettingsWrapper.getLockScreenCustomClockFace(anyInt())).thenReturn(BUBBLE_CLOCK); |
Robert Snoeberger | 71e5079 | 2019-02-15 15:48:01 -0500 | [diff] [blame] | 140 | // WHEN settings change event is fired |
Robert Snoeberger | be2a188 | 2019-04-10 13:48:02 -0400 | [diff] [blame] | 141 | mContentObserver.onChange(false, SETTINGS_URI, MAIN_USER_ID); |
Robert Snoeberger | 71e5079 | 2019-02-15 15:48:01 -0500 | [diff] [blame] | 142 | // THEN the plugin is the bubble clock face. |
| 143 | assertThat(mClockManager.getCurrentClock()).isInstanceOf(BUBBLE_CLOCK_CLASS); |
| 144 | } |
| 145 | |
| 146 | @Test |
shawnlin | f443938 | 2019-05-23 20:44:49 +0800 | [diff] [blame] | 147 | public void getCurrentClock_inBlackList() { |
| 148 | mClockManager = spy(mClockManager); |
| 149 | // GIVEN that settings is set to the bubble clock face |
| 150 | when(mMockSettingsWrapper.getLockScreenCustomClockFace(anyInt())).thenReturn(BUBBLE_CLOCK); |
| 151 | // WHEN settings change event is fired |
| 152 | mContentObserver.onChange(false, SETTINGS_URI, MAIN_USER_ID); |
| 153 | // GIVEN that bubble clock is in blacklist |
| 154 | when(mClockManager.getBlackListFromConfig()).thenReturn(BUBBLE_CLOCK); |
| 155 | // WHEN device config change of systemui is fired |
| 156 | mClockManager.onDeviceConfigPropertiesChanged(DeviceConfig.NAMESPACE_SYSTEMUI); |
| 157 | // THEN the result is null, indicated the current clock should be reset to the default one. |
| 158 | assertThat(mClockManager.getCurrentClock()).isNull(); |
| 159 | } |
| 160 | |
| 161 | @Test |
| 162 | public void getClockInfo_inBlackList() { |
| 163 | mClockManager = spy(mClockManager); |
| 164 | // GIVEN that bubble clock is in blacklist |
| 165 | when(mClockManager.getBlackListFromConfig()).thenReturn(BUBBLE_CLOCK); |
| 166 | // WHEN device config change of systemui is fired |
| 167 | mClockManager.onDeviceConfigPropertiesChanged(DeviceConfig.NAMESPACE_SYSTEMUI); |
| 168 | // THEN the ClockInfo should not contain bubble clock |
| 169 | List<ClockInfo> clocks = mClockManager.getClockInfos(); |
| 170 | assertThat(clocks.stream().anyMatch(info -> BUBBLE_CLOCK.equals(info.getId()))).isFalse(); |
| 171 | } |
| 172 | |
| 173 | @Test |
Robert Snoeberger | d8445ea | 2019-03-27 10:41:23 -0400 | [diff] [blame] | 174 | public void onClockChanged_customClock() { |
| 175 | // GIVEN that settings is set to the bubble clock face |
Robert Snoeberger | 372e13f | 2019-04-08 17:07:14 -0400 | [diff] [blame] | 176 | when(mMockSettingsWrapper.getLockScreenCustomClockFace(anyInt())).thenReturn(BUBBLE_CLOCK); |
Robert Snoeberger | d8445ea | 2019-03-27 10:41:23 -0400 | [diff] [blame] | 177 | // WHEN settings change event is fired |
Robert Snoeberger | be2a188 | 2019-04-10 13:48:02 -0400 | [diff] [blame] | 178 | mContentObserver.onChange(false, SETTINGS_URI, MAIN_USER_ID); |
Robert Snoeberger | d8445ea | 2019-03-27 10:41:23 -0400 | [diff] [blame] | 179 | // THEN the plugin is the bubble clock face. |
| 180 | ArgumentCaptor<ClockPlugin> captor = ArgumentCaptor.forClass(ClockPlugin.class); |
| 181 | verify(mMockListener1).onClockChanged(captor.capture()); |
| 182 | assertThat(captor.getValue()).isInstanceOf(BUBBLE_CLOCK_CLASS); |
| 183 | } |
| 184 | |
| 185 | @Test |
| 186 | public void onClockChanged_uniqueInstances() { |
| 187 | // GIVEN that settings is set to the bubble clock face |
Robert Snoeberger | 372e13f | 2019-04-08 17:07:14 -0400 | [diff] [blame] | 188 | when(mMockSettingsWrapper.getLockScreenCustomClockFace(anyInt())).thenReturn(BUBBLE_CLOCK); |
Robert Snoeberger | d8445ea | 2019-03-27 10:41:23 -0400 | [diff] [blame] | 189 | // WHEN settings change event is fired |
Robert Snoeberger | be2a188 | 2019-04-10 13:48:02 -0400 | [diff] [blame] | 190 | mContentObserver.onChange(false, SETTINGS_URI, MAIN_USER_ID); |
Robert Snoeberger | d8445ea | 2019-03-27 10:41:23 -0400 | [diff] [blame] | 191 | // THEN the listeners receive separate instances of the Bubble clock plugin. |
| 192 | ArgumentCaptor<ClockPlugin> captor1 = ArgumentCaptor.forClass(ClockPlugin.class); |
| 193 | ArgumentCaptor<ClockPlugin> captor2 = ArgumentCaptor.forClass(ClockPlugin.class); |
| 194 | verify(mMockListener1).onClockChanged(captor1.capture()); |
| 195 | verify(mMockListener2).onClockChanged(captor2.capture()); |
| 196 | assertThat(captor1.getValue()).isInstanceOf(BUBBLE_CLOCK_CLASS); |
| 197 | assertThat(captor2.getValue()).isInstanceOf(BUBBLE_CLOCK_CLASS); |
| 198 | assertThat(captor1.getValue()).isNotSameAs(captor2.getValue()); |
| 199 | } |
| 200 | |
| 201 | @Test |
Robert Snoeberger | 71e5079 | 2019-02-15 15:48:01 -0500 | [diff] [blame] | 202 | public void getCurrentClock_badSettingsValue() { |
| 203 | // GIVEN that settings contains a value that doesn't correspond to a |
| 204 | // custom clock face. |
Robert Snoeberger | 372e13f | 2019-04-08 17:07:14 -0400 | [diff] [blame] | 205 | when(mMockSettingsWrapper.getLockScreenCustomClockFace(anyInt())).thenReturn("bad value"); |
Robert Snoeberger | 71e5079 | 2019-02-15 15:48:01 -0500 | [diff] [blame] | 206 | // WHEN settings change event is fired |
Robert Snoeberger | be2a188 | 2019-04-10 13:48:02 -0400 | [diff] [blame] | 207 | mContentObserver.onChange(false, SETTINGS_URI, MAIN_USER_ID); |
Robert Snoeberger | 71e5079 | 2019-02-15 15:48:01 -0500 | [diff] [blame] | 208 | // THEN the result is null. |
| 209 | assertThat(mClockManager.getCurrentClock()).isNull(); |
| 210 | } |
| 211 | |
| 212 | @Test |
| 213 | public void getCurrentClock_dockedDefault() { |
| 214 | // WHEN dock event is fired |
| 215 | mFakeDockManager.setDockEvent(DockManager.STATE_DOCKED); |
| 216 | // THEN the result is null, indicating the default clock face. |
| 217 | assertThat(mClockManager.getCurrentClock()).isNull(); |
| 218 | } |
| 219 | |
| 220 | @Test |
| 221 | public void getCurrentClock_dockedCustomClock() { |
| 222 | // GIVEN settings is set to the bubble clock face |
Robert Snoeberger | 372e13f | 2019-04-08 17:07:14 -0400 | [diff] [blame] | 223 | when(mMockSettingsWrapper.getDockedClockFace(anyInt())).thenReturn(BUBBLE_CLOCK); |
Robert Snoeberger | 71e5079 | 2019-02-15 15:48:01 -0500 | [diff] [blame] | 224 | // WHEN dock event fires |
| 225 | mFakeDockManager.setDockEvent(DockManager.STATE_DOCKED); |
| 226 | // THEN the plugin is the bubble clock face. |
| 227 | assertThat(mClockManager.getCurrentClock()).isInstanceOf(BUBBLE_CLOCK_CLASS); |
| 228 | } |
| 229 | |
| 230 | @Test |
| 231 | public void getCurrentClock_badDockedSettingsValue() { |
| 232 | // GIVEN settings contains a value that doesn't correspond to an available clock face. |
Robert Snoeberger | 372e13f | 2019-04-08 17:07:14 -0400 | [diff] [blame] | 233 | when(mMockSettingsWrapper.getDockedClockFace(anyInt())).thenReturn("bad value"); |
Robert Snoeberger | 71e5079 | 2019-02-15 15:48:01 -0500 | [diff] [blame] | 234 | // WHEN dock event fires |
| 235 | mFakeDockManager.setDockEvent(DockManager.STATE_DOCKED); |
| 236 | // THEN the result is null. |
| 237 | assertThat(mClockManager.getCurrentClock()).isNull(); |
| 238 | } |
| 239 | |
| 240 | @Test |
| 241 | public void getCurrentClock_badDockedSettingsFallback() { |
| 242 | // GIVEN settings contains a value that doesn't correspond to an available clock face, but |
| 243 | // locked screen settings is set to bubble clock. |
Robert Snoeberger | 372e13f | 2019-04-08 17:07:14 -0400 | [diff] [blame] | 244 | when(mMockSettingsWrapper.getDockedClockFace(anyInt())).thenReturn("bad value"); |
| 245 | when(mMockSettingsWrapper.getLockScreenCustomClockFace(anyInt())).thenReturn(BUBBLE_CLOCK); |
Robert Snoeberger | 71e5079 | 2019-02-15 15:48:01 -0500 | [diff] [blame] | 246 | // WHEN dock event is fired |
| 247 | mFakeDockManager.setDockEvent(DockManager.STATE_DOCKED); |
| 248 | // THEN the plugin is the bubble clock face. |
| 249 | assertThat(mClockManager.getCurrentClock()).isInstanceOf(BUBBLE_CLOCK_CLASS); |
| 250 | } |
Robert Snoeberger | be2a188 | 2019-04-10 13:48:02 -0400 | [diff] [blame] | 251 | |
| 252 | @Test |
| 253 | public void onUserChanged_defaultClock() { |
| 254 | // WHEN the user changes |
| 255 | mCurrentUser.setValue(SECONDARY_USER_ID); |
| 256 | // THEN the plugin is null for the default clock face |
| 257 | assertThat(mClockManager.getCurrentClock()).isNull(); |
| 258 | } |
| 259 | |
| 260 | @Test |
| 261 | public void onUserChanged_customClock() { |
| 262 | // GIVEN that a second user has selected the bubble clock face |
| 263 | when(mMockSettingsWrapper.getLockScreenCustomClockFace(SECONDARY_USER_ID)).thenReturn( |
| 264 | BUBBLE_CLOCK); |
| 265 | // WHEN the user changes |
| 266 | mCurrentUser.setValue(SECONDARY_USER_ID); |
| 267 | // THEN the plugin is the bubble clock face. |
| 268 | assertThat(mClockManager.getCurrentClock()).isInstanceOf(BUBBLE_CLOCK_CLASS); |
| 269 | } |
| 270 | |
| 271 | @Test |
| 272 | public void onUserChanged_docked() { |
| 273 | // GIVEN device is docked |
| 274 | mFakeDockManager.setDockEvent(DockManager.STATE_DOCKED); |
| 275 | // AND the second user as selected the bubble clock for the dock |
| 276 | when(mMockSettingsWrapper.getDockedClockFace(SECONDARY_USER_ID)).thenReturn(BUBBLE_CLOCK); |
| 277 | // WHEN the user changes |
| 278 | mCurrentUser.setValue(SECONDARY_USER_ID); |
| 279 | // THEN the plugin is the bubble clock face. |
| 280 | assertThat(mClockManager.getCurrentClock()).isInstanceOf(BUBBLE_CLOCK_CLASS); |
| 281 | } |
Robert Snoeberger | b300a4e | 2019-02-13 20:13:53 +0000 | [diff] [blame] | 282 | } |