Deprecate SettingsDrawerActivity.openTile.

Use DashboardFeatureProvider to open tile instead. This makes logic more
centralized in one place, and makes logging easier in the future.

Bug: 30137094
Test: RunSettingsRoboTests
Change-Id: I8a028bb7cac8f70f6c237f253be8668cc3ef257e
This commit is contained in:
Fan Zhang
2017-02-13 14:24:36 -08:00
parent 33b0a66aee
commit 628b3cb76e
4 changed files with 71 additions and 18 deletions

View File

@@ -50,6 +50,7 @@ import java.util.ArrayList;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
@@ -140,6 +141,27 @@ public class DashboardFeatureProviderImplTest {
verify(mActivity).getFragmentManager();
}
@Test
public void bindPreference_noFragmentMetadataSingleUser_shouldBindToDirectLaunchIntent() {
final Preference preference = new Preference(
ShadowApplication.getInstance().getApplicationContext());
final Tile tile = new Tile();
tile.metaData = new Bundle();
tile.userHandle = new ArrayList<>();
tile.userHandle.add(mock(UserHandle.class));
tile.intent = new Intent();
tile.intent.setComponent(new ComponentName("pkg", "class"));
when(mActivity.getSystemService(Context.USER_SERVICE))
.thenReturn(mUserManager);
mImpl.bindPreferenceToTile(mActivity, preference, tile, "123", Preference.DEFAULT_ORDER);
preference.getOnPreferenceClickListener().onPreferenceClick(null);
verify(mActivity)
.startActivityForResultAsUser(any(Intent.class), anyInt(), any(UserHandle.class));
}
@Test
public void bindPreference_withNullKeyNullPriority_shouldGenerateKeyAndPriority() {
final Preference preference = new Preference(