1 /* 2 * Copyright (C) 2016 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 17 package com.android.settings.dashboard; 18 19 import static android.content.Intent.EXTRA_USER; 20 21 import static com.android.settingslib.drawer.TileUtils.META_DATA_KEY_ORDER; 22 import static com.android.settingslib.drawer.TileUtils.META_DATA_KEY_PROFILE; 23 import static com.android.settingslib.drawer.TileUtils.META_DATA_PREFERENCE_KEYHINT; 24 import static com.android.settingslib.drawer.TileUtils.META_DATA_PREFERENCE_SUMMARY; 25 import static com.android.settingslib.drawer.TileUtils.META_DATA_PREFERENCE_TITLE; 26 import static com.android.settingslib.drawer.TileUtils.PROFILE_ALL; 27 import static com.android.settingslib.drawer.TileUtils.PROFILE_PRIMARY; 28 29 import static com.google.common.truth.Truth.assertThat; 30 31 import static org.mockito.ArgumentMatchers.any; 32 import static org.mockito.ArgumentMatchers.anyInt; 33 import static org.mockito.ArgumentMatchers.eq; 34 import static org.mockito.Mockito.doReturn; 35 import static org.mockito.Mockito.mock; 36 import static org.mockito.Mockito.never; 37 import static org.mockito.Mockito.spy; 38 import static org.mockito.Mockito.verify; 39 import static org.mockito.Mockito.verifyZeroInteractions; 40 import static org.mockito.Mockito.when; 41 42 import android.content.Context; 43 import android.content.Intent; 44 import android.content.pm.ActivityInfo; 45 import android.content.pm.PackageManager; 46 import android.content.pm.ResolveInfo; 47 import android.graphics.Bitmap; 48 import android.graphics.drawable.Icon; 49 import android.os.Bundle; 50 import android.os.UserHandle; 51 import android.os.UserManager; 52 53 import androidx.fragment.app.FragmentActivity; 54 import androidx.preference.Preference; 55 56 import com.android.internal.logging.nano.MetricsProto.MetricsEvent; 57 import com.android.settings.R; 58 import com.android.settings.SettingsActivity; 59 import com.android.settings.testutils.FakeFeatureFactory; 60 import com.android.settings.testutils.shadow.ShadowThreadUtils; 61 import com.android.settings.testutils.shadow.ShadowTileUtils; 62 import com.android.settings.testutils.shadow.ShadowUserManager; 63 import com.android.settingslib.core.instrumentation.MetricsFeatureProvider; 64 import com.android.settingslib.drawer.CategoryKey; 65 import com.android.settingslib.drawer.Tile; 66 import com.android.settingslib.drawer.TileUtils; 67 68 import org.junit.Before; 69 import org.junit.Test; 70 import org.junit.runner.RunWith; 71 import org.mockito.Answers; 72 import org.mockito.ArgumentCaptor; 73 import org.mockito.Mock; 74 import org.mockito.MockitoAnnotations; 75 import org.robolectric.Robolectric; 76 import org.robolectric.RobolectricTestRunner; 77 import org.robolectric.RuntimeEnvironment; 78 import org.robolectric.Shadows; 79 import org.robolectric.annotation.Config; 80 import org.robolectric.shadows.ShadowActivity; 81 import org.robolectric.util.ReflectionHelpers; 82 83 import java.util.ArrayList; 84 85 @RunWith(RobolectricTestRunner.class) 86 @Config(shadows = ShadowUserManager.class) 87 public class DashboardFeatureProviderImplTest { 88 89 @Mock(answer = Answers.RETURNS_DEEP_STUBS) 90 private FragmentActivity mActivity; 91 @Mock(answer = Answers.RETURNS_DEEP_STUBS) 92 private UserManager mUserManager; 93 @Mock 94 private PackageManager mPackageManager; 95 private FakeFeatureFactory mFeatureFactory; 96 97 private Context mContext; 98 private ActivityInfo mActivityInfo; 99 private DashboardFeatureProviderImpl mImpl; 100 private boolean mForceRoundedIcon; 101 102 @Before setUp()103 public void setUp() { 104 MockitoAnnotations.initMocks(this); 105 mContext = spy(RuntimeEnvironment.application); 106 doReturn(RuntimeEnvironment.application).when(mActivity).getApplicationContext(); 107 mForceRoundedIcon = false; 108 mActivityInfo = new ActivityInfo(); 109 mActivityInfo.packageName = mContext.getPackageName(); 110 mActivityInfo.name = "class"; 111 mActivityInfo.metaData = new Bundle(); 112 mActivityInfo.metaData.putInt(META_DATA_PREFERENCE_TITLE, R.string.settings_label); 113 mActivityInfo.metaData.putInt(META_DATA_PREFERENCE_SUMMARY, 114 R.string.about_settings_summary); 115 doReturn(mPackageManager).when(mContext).getPackageManager(); 116 when(mPackageManager.resolveActivity(any(Intent.class), anyInt())) 117 .thenReturn(new ResolveInfo()); 118 mFeatureFactory = FakeFeatureFactory.setupForTest(); 119 mImpl = new DashboardFeatureProviderImpl(mContext); 120 } 121 122 @Test shouldHoldAppContext()123 public void shouldHoldAppContext() { 124 assertThat(mImpl.mContext).isEqualTo(mContext.getApplicationContext()); 125 } 126 127 @Test bindPreference_shouldBindAllData()128 public void bindPreference_shouldBindAllData() { 129 final Preference preference = new Preference(RuntimeEnvironment.application); 130 final Tile tile = spy(new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE)); 131 mActivityInfo.metaData.putInt(META_DATA_KEY_ORDER, 10); 132 doReturn(Icon.createWithBitmap(Bitmap.createBitmap(1, 1, Bitmap.Config.RGB_565))) 133 .when(tile).getIcon(any(Context.class)); 134 mActivityInfo.metaData.putString(SettingsActivity.META_DATA_KEY_FRAGMENT_CLASS, "HI"); 135 mImpl.bindPreferenceToTile(mActivity, mForceRoundedIcon, MetricsEvent.SETTINGS_GESTURES, 136 preference, tile, "123", Preference.DEFAULT_ORDER); 137 138 assertThat(preference.getTitle()).isEqualTo(mContext.getText(R.string.settings_label)); 139 assertThat(preference.getSummary()) 140 .isEqualTo(mContext.getText(R.string.about_settings_summary)); 141 assertThat(preference.getIcon()).isNotNull(); 142 assertThat(preference.getFragment()).isEqualTo( 143 mActivityInfo.metaData.getString(SettingsActivity.META_DATA_KEY_FRAGMENT_CLASS)); 144 assertThat(preference.getOrder()).isEqualTo(tile.getOrder()); 145 } 146 147 @Test bindPreference_noFragmentMetadata_shouldBindIntent()148 public void bindPreference_noFragmentMetadata_shouldBindIntent() { 149 final Preference preference = new Preference(RuntimeEnvironment.application); 150 mActivityInfo.metaData.putInt(META_DATA_KEY_ORDER, 10); 151 final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE); 152 153 mImpl.bindPreferenceToTile(mActivity, mForceRoundedIcon, MetricsEvent.SETTINGS_GESTURES, 154 preference, tile, "123", Preference.DEFAULT_ORDER); 155 156 assertThat(preference.getFragment()).isNull(); 157 assertThat(preference.getOnPreferenceClickListener()).isNotNull(); 158 assertThat(preference.getOrder()).isEqualTo(tile.getOrder()); 159 } 160 161 @Test bindPreference_noFragmentMetadata_shouldBindToProfileSelector()162 public void bindPreference_noFragmentMetadata_shouldBindToProfileSelector() { 163 final Preference preference = new Preference(RuntimeEnvironment.application); 164 final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE); 165 tile.userHandle = new ArrayList<>(); 166 tile.userHandle.add(mock(UserHandle.class)); 167 tile.userHandle.add(mock(UserHandle.class)); 168 169 mImpl.bindPreferenceToTile(mActivity, mForceRoundedIcon, MetricsEvent.SETTINGS_GESTURES, 170 preference, tile, "123", Preference.DEFAULT_ORDER); 171 preference.getOnPreferenceClickListener().onPreferenceClick(null); 172 173 verify(mActivity).getSupportFragmentManager(); 174 } 175 176 @Test bindPreference_noFragmentMetadataSingleUser_shouldBindToDirectLaunchIntent()177 public void bindPreference_noFragmentMetadataSingleUser_shouldBindToDirectLaunchIntent() { 178 final Preference preference = new Preference(RuntimeEnvironment.application); 179 final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE); 180 tile.userHandle = new ArrayList<>(); 181 tile.userHandle.add(mock(UserHandle.class)); 182 183 when(mActivity.getSystemService(Context.USER_SERVICE)) 184 .thenReturn(mUserManager); 185 186 mImpl.bindPreferenceToTile(mActivity, mForceRoundedIcon, MetricsEvent.SETTINGS_GESTURES, 187 preference, tile, "123", Preference.DEFAULT_ORDER); 188 preference.getOnPreferenceClickListener().onPreferenceClick(null); 189 190 verify(mFeatureFactory.metricsFeatureProvider).logDashboardStartIntent( 191 any(Context.class), 192 any(Intent.class), 193 eq(MetricsEvent.SETTINGS_GESTURES)); 194 verify(mActivity) 195 .startActivityForResultAsUser(any(Intent.class), anyInt(), any(UserHandle.class)); 196 } 197 198 @Test bindPreference_toInternalSettingActivity_shouldBindToDirectLaunchIntentAndNotLog()199 public void bindPreference_toInternalSettingActivity_shouldBindToDirectLaunchIntentAndNotLog() { 200 final Preference preference = new Preference(RuntimeEnvironment.application); 201 mActivityInfo.packageName = RuntimeEnvironment.application.getPackageName(); 202 final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE); 203 tile.userHandle = new ArrayList<>(); 204 tile.userHandle.add(mock(UserHandle.class)); 205 206 mImpl.bindPreferenceToTile(mActivity, mForceRoundedIcon, MetricsEvent.SETTINGS_GESTURES, 207 preference, tile, "123", Preference.DEFAULT_ORDER); 208 preference.getOnPreferenceClickListener().onPreferenceClick(null); 209 verify(mFeatureFactory.metricsFeatureProvider).logDashboardStartIntent( 210 any(Context.class), 211 any(Intent.class), 212 anyInt()); 213 verify(mActivity) 214 .startActivityForResultAsUser(any(Intent.class), anyInt(), any(UserHandle.class)); 215 } 216 217 @Test bindPreference_nullPreference_shouldIgnore()218 public void bindPreference_nullPreference_shouldIgnore() { 219 final Tile tile = mock(Tile.class); 220 mImpl.bindPreferenceToTile(mActivity, mForceRoundedIcon, MetricsEvent.VIEW_UNKNOWN, 221 null, tile, "123", Preference.DEFAULT_ORDER); 222 223 verifyZeroInteractions(tile); 224 } 225 226 @Test bindPreference_withNullKeyNullPriority_shouldGenerateKeyAndPriority()227 public void bindPreference_withNullKeyNullPriority_shouldGenerateKeyAndPriority() { 228 final Preference preference = new Preference(RuntimeEnvironment.application); 229 final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE); 230 mImpl.bindPreferenceToTile(mActivity, mForceRoundedIcon, MetricsEvent.VIEW_UNKNOWN, 231 preference, tile, null /*key */, Preference.DEFAULT_ORDER); 232 233 assertThat(preference.getKey()).isNotNull(); 234 assertThat(preference.getOrder()).isEqualTo(Preference.DEFAULT_ORDER); 235 } 236 237 @Test bindPreference_noSummary_shouldSetSummaryToPlaceholder()238 public void bindPreference_noSummary_shouldSetSummaryToPlaceholder() { 239 final Preference preference = new Preference(RuntimeEnvironment.application); 240 mActivityInfo.metaData.remove(META_DATA_PREFERENCE_SUMMARY); 241 242 final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE); 243 244 mImpl.bindPreferenceToTile(mActivity, mForceRoundedIcon, MetricsEvent.VIEW_UNKNOWN, 245 preference, tile, null /*key */, Preference.DEFAULT_ORDER); 246 247 assertThat(preference.getSummary()) 248 .isEqualTo(RuntimeEnvironment.application.getString(R.string.summary_placeholder)); 249 } 250 251 @Test 252 @Config(shadows = {ShadowTileUtils.class, ShadowThreadUtils.class}) bindPreference_hasSummaryUri_shouldLoadSummaryFromContentProvider()253 public void bindPreference_hasSummaryUri_shouldLoadSummaryFromContentProvider() { 254 final Preference preference = new Preference(RuntimeEnvironment.application); 255 final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE); 256 mActivityInfo.metaData.putString(TileUtils.META_DATA_PREFERENCE_SUMMARY_URI, 257 "content://com.android.settings/tile_summary"); 258 259 mImpl.bindPreferenceToTile(mActivity, mForceRoundedIcon, MetricsEvent.VIEW_UNKNOWN, 260 preference, tile, null /*key */, Preference.DEFAULT_ORDER); 261 262 assertThat(preference.getSummary()).isEqualTo(ShadowTileUtils.MOCK_SUMMARY); 263 } 264 265 @Test bindPreference_withNullKeyTileKey_shouldUseTileKey()266 public void bindPreference_withNullKeyTileKey_shouldUseTileKey() { 267 final Preference preference = new Preference(RuntimeEnvironment.application); 268 mActivityInfo.metaData.putString(META_DATA_PREFERENCE_KEYHINT, "key"); 269 final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE); 270 mImpl.bindPreferenceToTile(mActivity, mForceRoundedIcon, MetricsEvent.VIEW_UNKNOWN, 271 preference, tile, null /* key */, Preference.DEFAULT_ORDER); 272 273 assertThat(preference.getKey()).isEqualTo(tile.getKey(mContext)); 274 } 275 276 @Test 277 @Config(shadows = {ShadowTileUtils.class, ShadowThreadUtils.class}) bindPreference_withIconUri_shouldLoadIconFromContentProvider()278 public void bindPreference_withIconUri_shouldLoadIconFromContentProvider() { 279 final Preference preference = new Preference(RuntimeEnvironment.application); 280 mActivityInfo.packageName = RuntimeEnvironment.application.getPackageName(); 281 final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE); 282 mActivityInfo.metaData.putString(META_DATA_PREFERENCE_KEYHINT, "key"); 283 mActivityInfo.metaData.putString(TileUtils.META_DATA_PREFERENCE_ICON_URI, 284 "content://com.android.settings/tile_icon"); 285 mImpl.bindIcon(preference, tile, false /* forceRoundedIcon */); 286 287 assertThat(preference.getIcon()).isNotNull(); 288 } 289 290 @Test bindPreference_withBaseOrder_shouldOffsetOrder()291 public void bindPreference_withBaseOrder_shouldOffsetOrder() { 292 final int baseOrder = 100; 293 final Preference preference = new Preference(RuntimeEnvironment.application); 294 mActivityInfo.metaData.putInt(META_DATA_KEY_ORDER, 10); 295 final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE); 296 297 mImpl.bindPreferenceToTile(mActivity, mForceRoundedIcon, MetricsEvent.VIEW_UNKNOWN, 298 preference, tile, "123", baseOrder); 299 300 assertThat(preference.getOrder()).isEqualTo(tile.getOrder() + baseOrder); 301 } 302 303 @Test bindPreference_withOrderMetadata_shouldUseOrderInMetadata()304 public void bindPreference_withOrderMetadata_shouldUseOrderInMetadata() { 305 final Preference preference = new Preference(RuntimeEnvironment.application); 306 final int testOrder = -30; 307 mActivityInfo.metaData.putInt(META_DATA_KEY_ORDER, 10); 308 final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE); 309 mActivityInfo.metaData.putInt(META_DATA_KEY_ORDER, testOrder); 310 mImpl.bindPreferenceToTile(mActivity, mForceRoundedIcon, MetricsEvent.VIEW_UNKNOWN, 311 preference, tile, "123", Preference.DEFAULT_ORDER); 312 313 assertThat(preference.getOrder()).isEqualTo(testOrder); 314 } 315 316 @Test bindPreference_invalidOrderMetadata_shouldIgnore()317 public void bindPreference_invalidOrderMetadata_shouldIgnore() { 318 final Preference preference = new Preference(RuntimeEnvironment.application); 319 final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE); 320 mActivityInfo.metaData.putString(META_DATA_KEY_ORDER, "hello"); 321 322 mImpl.bindPreferenceToTile(mActivity, mForceRoundedIcon, MetricsEvent.VIEW_UNKNOWN, 323 preference, tile, "123", Preference.DEFAULT_ORDER); 324 325 assertThat(preference.getOrder()).isEqualTo(Preference.DEFAULT_ORDER); 326 } 327 328 @Test bindPreference_withIntentActionMetadata_shouldSetLaunchAction()329 public void bindPreference_withIntentActionMetadata_shouldSetLaunchAction() { 330 FragmentActivity activity = Robolectric.buildActivity(FragmentActivity.class).get(); 331 final Preference preference = new Preference(RuntimeEnvironment.application); 332 final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE); 333 mActivityInfo.metaData.putString(META_DATA_PREFERENCE_KEYHINT, "key"); 334 mActivityInfo.metaData.putString("com.android.settings.intent.action", "TestAction"); 335 tile.userHandle = null; 336 mImpl.bindPreferenceToTile(activity, mForceRoundedIcon, MetricsEvent.SETTINGS_GESTURES, 337 preference, tile, "123", Preference.DEFAULT_ORDER); 338 preference.performClick(); 339 ShadowActivity shadowActivity = Shadows.shadowOf(activity); 340 341 final Intent launchIntent = shadowActivity.getNextStartedActivityForResult().intent; 342 assertThat(launchIntent.getAction()) 343 .isEqualTo("TestAction"); 344 assertThat(launchIntent.getIntExtra(MetricsFeatureProvider.EXTRA_SOURCE_METRICS_CATEGORY, 0)) 345 .isEqualTo(MetricsEvent.SETTINGS_GESTURES); 346 } 347 348 @Test clickPreference_withUnresolvableIntent_shouldNotLaunchAnything()349 public void clickPreference_withUnresolvableIntent_shouldNotLaunchAnything() { 350 ReflectionHelpers.setField( 351 mImpl, "mPackageManager", RuntimeEnvironment.application.getPackageManager()); 352 FragmentActivity activity = Robolectric.buildActivity(FragmentActivity.class).get(); 353 final Preference preference = new Preference(RuntimeEnvironment.application); 354 final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE); 355 mActivityInfo.metaData.putString(META_DATA_PREFERENCE_KEYHINT, "key"); 356 mActivityInfo.metaData.putString("com.android.settings.intent.action", "TestAction"); 357 tile.userHandle = null; 358 359 mImpl.bindPreferenceToTile(activity, mForceRoundedIcon, MetricsEvent.SETTINGS_GESTURES, 360 preference, tile, "123", Preference.DEFAULT_ORDER); 361 preference.performClick(); 362 363 final ShadowActivity.IntentForResult launchIntent = 364 Shadows.shadowOf(activity).getNextStartedActivityForResult(); 365 366 assertThat(launchIntent).isNull(); 367 } 368 369 @Test openTileIntent_profileSelectionDialog_shouldShow()370 public void openTileIntent_profileSelectionDialog_shouldShow() { 371 ShadowUserManager.getShadow().addUser(10, "Someone", 0); 372 373 final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE); 374 final ArrayList<UserHandle> handles = new ArrayList<>(); 375 handles.add(new UserHandle(0)); 376 handles.add(new UserHandle(10)); 377 tile.userHandle = handles; 378 mImpl.openTileIntent(mActivity, tile); 379 380 verify(mActivity, never()) 381 .startActivityForResult(any(Intent.class), eq(0)); 382 verify(mActivity).getSupportFragmentManager(); 383 } 384 385 @Test openTileIntent_profileSelectionDialog_explicitMetadataShouldShow()386 public void openTileIntent_profileSelectionDialog_explicitMetadataShouldShow() { 387 ShadowUserManager.getShadow().addUser(10, "Someone", 0); 388 389 mActivityInfo.metaData.putString(META_DATA_KEY_PROFILE, PROFILE_ALL); 390 final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE); 391 final ArrayList<UserHandle> handles = new ArrayList<>(); 392 handles.add(new UserHandle(0)); 393 handles.add(new UserHandle(10)); 394 tile.userHandle = handles; 395 mImpl.openTileIntent(mActivity, tile); 396 397 verify(mActivity, never()) 398 .startActivityForResult(any(Intent.class), eq(0)); 399 verify(mActivity).getSupportFragmentManager(); 400 } 401 402 @Test openTileIntent_profileSelectionDialog_shouldNotShow()403 public void openTileIntent_profileSelectionDialog_shouldNotShow() { 404 ShadowUserManager.getShadow().addUser(10, "Someone", 0); 405 406 mActivityInfo.metaData.putString(META_DATA_KEY_PROFILE, PROFILE_PRIMARY); 407 final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE); 408 final ArrayList<UserHandle> handles = new ArrayList<>(); 409 handles.add(new UserHandle(0)); 410 handles.add(new UserHandle(10)); 411 tile.userHandle = handles; 412 mImpl.openTileIntent(mActivity, tile); 413 414 verify(mActivity) 415 .startActivityForResult(any(Intent.class), eq(0)); 416 verify(mActivity, never()).getSupportFragmentManager(); 417 } 418 419 @Test openTileIntent_profileSelectionDialog_validUserHandleShouldNotShow()420 public void openTileIntent_profileSelectionDialog_validUserHandleShouldNotShow() { 421 final int userId = 10; 422 ShadowUserManager.getShadow().addUser(userId, "Someone", 0); 423 424 final UserHandle userHandle = new UserHandle(userId); 425 final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE); 426 tile.getIntent().putExtra(EXTRA_USER, userHandle); 427 final ArrayList<UserHandle> handles = new ArrayList<>(); 428 handles.add(new UserHandle(0)); 429 handles.add(userHandle); 430 tile.userHandle = handles; 431 432 mImpl.openTileIntent(mActivity, tile); 433 434 final ArgumentCaptor<UserHandle> argument = ArgumentCaptor.forClass(UserHandle.class); 435 verify(mActivity) 436 .startActivityForResultAsUser(any(Intent.class), anyInt(), argument.capture()); 437 assertThat(argument.getValue().getIdentifier()).isEqualTo(userId); 438 verify(mActivity, never()).getSupportFragmentManager(); 439 } 440 441 @Test openTileIntent_profileSelectionDialog_invalidUserHandleShouldShow()442 public void openTileIntent_profileSelectionDialog_invalidUserHandleShouldShow() { 443 ShadowUserManager.getShadow().addUser(10, "Someone", 0); 444 445 final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE); 446 tile.getIntent().putExtra(EXTRA_USER, new UserHandle(30)); 447 final ArrayList<UserHandle> handles = new ArrayList<>(); 448 handles.add(new UserHandle(0)); 449 handles.add(new UserHandle(10)); 450 tile.userHandle = handles; 451 452 mImpl.openTileIntent(mActivity, tile); 453 454 verify(mActivity, never()) 455 .startActivityForResultAsUser(any(Intent.class), anyInt(), any(UserHandle.class)); 456 verify(mActivity).getSupportFragmentManager(); 457 } 458 } 459