Add handling for account tiles for specific account type.

- List individual account instead of account type under User & account
  screen.

- Add handling to move account tiles with specific account type from
  top level account dashboard to inside the corresponding account
  preference.

- Rename settings.accounts.AccountPreference to
  settings.accounts.AccountTypePreference to make it less confused
  with settings.AccountPreference

Bug: 31801423
Test: make RunSettingsRoboTests
Change-Id: Iebe70a3c4230e8d979344f142a5c2a60945e552e
This commit is contained in:
Doris Ling
2016-11-22 16:37:06 -08:00
parent 737ae83a66
commit 20d4b041f7
15 changed files with 560 additions and 57 deletions

View File

@@ -15,18 +15,15 @@
*/
package com.android.settings.accounts;
import android.content.Context;
import android.os.Bundle;
import com.android.settings.TestConfig;
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settingslib.drawer.CategoryKey;
import com.android.settingslib.drawer.Tile;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Answers;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
@@ -36,21 +33,39 @@ import static com.google.common.truth.Truth.assertThat;
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
public class UserAndAccountDashboardFragmentTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private Context mContext;
private static final String METADATA_CATEGORY = "com.android.settings.category";
private static final String METADATA_ACCOUNT_TYPE = "com.android.settings.ia.account";
private UserAndAccountDashboardFragment mFragment;
private UserAndAccountDashboardFragment mFragment;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
FakeFeatureFactory.setupForTest(mContext);
mFragment = new UserAndAccountDashboardFragment();
}
@Before
public void setUp() {
mFragment = new UserAndAccountDashboardFragment();
}
@Test
public void testCategory_isConnectedDevice() {
assertThat(mFragment.getCategoryKey()).isEqualTo(CategoryKey.CATEGORY_ACCOUNT);
}
@Test
public void testCategory_isAccount() {
assertThat(mFragment.getCategoryKey()).isEqualTo(CategoryKey.CATEGORY_ACCOUNT);
}
@Test
public void refreshDashboardTiles_HasAccountType_shouldNotDisplay() {
final Tile tile = new Tile();
final Bundle metaData = new Bundle();
metaData.putString(METADATA_CATEGORY, CategoryKey.CATEGORY_ACCOUNT);
metaData.putString(METADATA_ACCOUNT_TYPE, "com.abc");
tile.metaData = metaData;
assertThat(mFragment.displayTile(tile)).isFalse();
}
@Test
public void refreshDashboardTiles_NoAccountType_shouldDisplay() {
final Tile tile = new Tile();
final Bundle metaData = new Bundle();
metaData.putString(METADATA_CATEGORY, CategoryKey.CATEGORY_ACCOUNT);
tile.metaData = metaData;
assertThat(mFragment.displayTile(tile)).isTrue();
}
}