diff options
author | 2020-01-16 16:54:08 +0800 | |
---|---|---|
committer | 2020-02-24 06:40:03 +0000 | |
commit | 74c58bb75f9153bd75f655b55d26de53c1ed8b26 (patch) | |
tree | 507ff04d6d04175f9a7eef14140103b440117001 | |
parent | 0cbd68abb6c9932bcaf1c778b94d33a9a356d9e5 (diff) |
Remove useless code
Fix: 150102523
Test: atest DocumentsUIGoogleTests
Change-Id: Ieb4c02f7de30d6573de874d6b4b9fe8bb837b2ba
19 files changed, 20 insertions, 307 deletions
diff --git a/src/com/android/documentsui/BaseActivity.java b/src/com/android/documentsui/BaseActivity.java index d0568c3af..e9f89eaa7 100644 --- a/src/com/android/documentsui/BaseActivity.java +++ b/src/com/android/documentsui/BaseActivity.java @@ -63,7 +63,6 @@ import com.android.documentsui.dirlist.AnimationView; import com.android.documentsui.dirlist.AppsRowManager; import com.android.documentsui.dirlist.DirectoryFragment; import com.android.documentsui.prefs.LocalPreferences; -import com.android.documentsui.prefs.Preferences; import com.android.documentsui.prefs.PreferencesMonitor; import com.android.documentsui.queries.CommandInterceptor; import com.android.documentsui.queries.SearchChipData; @@ -250,7 +249,7 @@ public abstract class BaseActivity ViewGroup chipGroup = findViewById(R.id.search_chip_group); mSearchManager = new SearchViewManager(searchListener, queryInterceptor, - chipGroup, icicle, mInjector.prefs::isRecordSearch); + chipGroup, icicle); // initialize the chip sets by accept mime types mSearchManager.initChipSets(mState.acceptMimes); // update the chip items by the mime types of the root @@ -293,7 +292,7 @@ public abstract class BaseActivity // For now, we only work with prefs that we backup. This // just limits the scope of what we expect to come flowing // through here until we know we want more and fancier options. - assert(Preferences.shouldBackup(pref)); + assert (LocalPreferences.shouldBackup(pref)); } @Override diff --git a/src/com/android/documentsui/DocumentsApplication.java b/src/com/android/documentsui/DocumentsApplication.java index fb479ac02..745da0afd 100644 --- a/src/com/android/documentsui/DocumentsApplication.java +++ b/src/com/android/documentsui/DocumentsApplication.java @@ -35,7 +35,6 @@ import com.android.documentsui.base.UserId; import com.android.documentsui.clipping.ClipStorage; import com.android.documentsui.clipping.ClipStore; import com.android.documentsui.clipping.DocumentClipper; -import com.android.documentsui.prefs.ScopedAccessLocalPreferences; import com.android.documentsui.queries.SearchHistoryManager; import com.android.documentsui.roots.ProvidersCache; import com.android.documentsui.theme.ThemeOverlayManager; @@ -138,7 +137,6 @@ public class DocumentsApplication extends Application { final IntentFilter localeFilter = new IntentFilter(); localeFilter.addAction(Intent.ACTION_LOCALE_CHANGED); registerReceiver(mCacheReceiver, localeFilter); - ScopedAccessLocalPreferences.clearScopedAccessPreferences(this); SearchHistoryManager.getInstance(getApplicationContext()); } diff --git a/src/com/android/documentsui/Injector.java b/src/com/android/documentsui/Injector.java index 5761566c1..82cbfcccb 100644 --- a/src/com/android/documentsui/Injector.java +++ b/src/com/android/documentsui/Injector.java @@ -33,7 +33,6 @@ import com.android.documentsui.base.Lookup; import com.android.documentsui.base.RootInfo; import com.android.documentsui.dirlist.AppsRowManager; import com.android.documentsui.picker.PickResult; -import com.android.documentsui.prefs.ScopedPreferences; import com.android.documentsui.queries.SearchViewManager; import com.android.documentsui.ui.DialogController; import com.android.documentsui.ui.MessageBuilder; @@ -50,7 +49,6 @@ public class Injector<T extends ActionHandler> { public final Features features; public final ActivityConfig config; - public final ScopedPreferences prefs; public final MessageBuilder messages; public final Lookup<String, String> fileTypeLookup; public final Consumer<Collection<RootInfo>> shortcutsUpdater; @@ -86,12 +84,11 @@ public class Injector<T extends ActionHandler> { public Injector( Features features, ActivityConfig config, - ScopedPreferences prefs, MessageBuilder messages, DialogController dialogs, Lookup<String, String> fileTypeLookup, Consumer<Collection<RootInfo>> shortcutsUpdater) { - this(features, config, prefs, messages, dialogs, fileTypeLookup, + this(features, config, messages, dialogs, fileTypeLookup, shortcutsUpdater, new Model(features)); } @@ -99,7 +96,6 @@ public class Injector<T extends ActionHandler> { public Injector( Features features, ActivityConfig config, - ScopedPreferences prefs, MessageBuilder messages, DialogController dialogs, Lookup<String, String> fileTypeLookup, @@ -108,7 +104,6 @@ public class Injector<T extends ActionHandler> { this.features = features; this.config = config; - this.prefs = prefs; this.messages = messages; this.dialogs = dialogs; this.fileTypeLookup = fileTypeLookup; diff --git a/src/com/android/documentsui/ShortcutsUpdater.java b/src/com/android/documentsui/ShortcutsUpdater.java index 4fe490727..e71d7bc93 100644 --- a/src/com/android/documentsui/ShortcutsUpdater.java +++ b/src/com/android/documentsui/ShortcutsUpdater.java @@ -27,7 +27,6 @@ import com.android.documentsui.base.Providers; import com.android.documentsui.base.RootInfo; import com.android.documentsui.base.Shared; import com.android.documentsui.files.FilesActivity; -import com.android.documentsui.prefs.ScopedPreferences; import java.util.ArrayList; import java.util.Collection; @@ -40,12 +39,10 @@ import java.util.Map; */ public final class ShortcutsUpdater { - private final ScopedPreferences mPrefs; private final Context mContext; - public ShortcutsUpdater(Context context, ScopedPreferences prefs) { + public ShortcutsUpdater(Context context) { mContext = context; - mPrefs = prefs; } public void update(Collection<RootInfo> roots) { diff --git a/src/com/android/documentsui/files/FilesActivity.java b/src/com/android/documentsui/files/FilesActivity.java index b281a7b8e..0837483dd 100644 --- a/src/com/android/documentsui/files/FilesActivity.java +++ b/src/com/android/documentsui/files/FilesActivity.java @@ -57,7 +57,6 @@ import com.android.documentsui.clipping.DocumentClipper; import com.android.documentsui.dirlist.AnimationView.AnimationType; import com.android.documentsui.dirlist.AppsRowManager; import com.android.documentsui.dirlist.DirectoryFragment; -import com.android.documentsui.prefs.ScopedPreferences; import com.android.documentsui.services.FileOperationService; import com.android.documentsui.sidebar.RootsFragment; import com.android.documentsui.ui.DialogController; @@ -92,16 +91,14 @@ public class FilesActivity extends BaseActivity implements AbstractActionHandler MessageBuilder messages = new MessageBuilder(this); Features features = Features.create(this); - ScopedPreferences prefs = ScopedPreferences.create(this, PREFERENCES_SCOPE); mInjector = new Injector<>( features, new Config(), - ScopedPreferences.create(this, PREFERENCES_SCOPE), messages, DialogController.create(features, this), DocumentsApplication.getFileTypeLookup(this), - new ShortcutsUpdater(this, prefs)::update); + new ShortcutsUpdater(this)::update); super.onCreate(icicle); diff --git a/src/com/android/documentsui/picker/PickActivity.java b/src/com/android/documentsui/picker/PickActivity.java index a9965305e..0e7e47ba9 100644 --- a/src/com/android/documentsui/picker/PickActivity.java +++ b/src/com/android/documentsui/picker/PickActivity.java @@ -60,7 +60,6 @@ import com.android.documentsui.base.Shared; import com.android.documentsui.base.State; import com.android.documentsui.dirlist.AppsRowManager; import com.android.documentsui.dirlist.DirectoryFragment; -import com.android.documentsui.prefs.ScopedPreferences; import com.android.documentsui.services.FileOperationService; import com.android.documentsui.sidebar.RootsFragment; import com.android.documentsui.ui.DialogController; @@ -90,12 +89,10 @@ public class PickActivity extends BaseActivity implements ActionHandler.Addons { public void onCreate(Bundle icicle) { Features features = Features.create(this); - ScopedPreferences prefs = ScopedPreferences.create(this, PREFERENCES_SCOPE); mInjector = new Injector<>( features, new Config(), - prefs, new MessageBuilder(this), DialogController.create(features, this), DocumentsApplication.getFileTypeLookup(this), diff --git a/src/com/android/documentsui/prefs/Preferences.java b/src/com/android/documentsui/prefs/Preferences.java deleted file mode 100644 index 8d856a50a..000000000 --- a/src/com/android/documentsui/prefs/Preferences.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (C) 2017 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.android.documentsui.prefs; - -public final class Preferences { - private Preferences() {} - - public static boolean shouldBackup(String s) { - return LocalPreferences.shouldBackup(s) || ScopedPreferences.shouldBackup(s); - } -} diff --git a/src/com/android/documentsui/prefs/PreferencesMonitor.java b/src/com/android/documentsui/prefs/PreferencesMonitor.java index 19ac5c60c..bd3b5195c 100644 --- a/src/com/android/documentsui/prefs/PreferencesMonitor.java +++ b/src/com/android/documentsui/prefs/PreferencesMonitor.java @@ -58,7 +58,7 @@ public final class PreferencesMonitor { // visible for use as a lambda, otherwise treat as a private. void onSharedPreferenceChanged(SharedPreferences prefs, String key) { - if (Preferences.shouldBackup(key)) { + if (LocalPreferences.shouldBackup(key)) { mChangeCallback.accept(key); BackupManager.dataChanged(mPackageName); } diff --git a/src/com/android/documentsui/prefs/PrefsBackupHelper.java b/src/com/android/documentsui/prefs/PrefsBackupHelper.java index 01b36bd36..d19e23bfc 100644 --- a/src/com/android/documentsui/prefs/PrefsBackupHelper.java +++ b/src/com/android/documentsui/prefs/PrefsBackupHelper.java @@ -19,6 +19,7 @@ import android.content.Context; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; import android.preference.PreferenceManager; + import androidx.annotation.VisibleForTesting; import java.util.Map; @@ -62,7 +63,7 @@ final class PrefsBackupHelper { private void copyMatchingPreferences(SharedPreferences source, Editor destination) { for (Map.Entry<String, ?> preference : source.getAll().entrySet()) { - if (Preferences.shouldBackup(preference.getKey())) { + if (LocalPreferences.shouldBackup(preference.getKey())) { setPreference(destination, preference); } } diff --git a/src/com/android/documentsui/prefs/ScopedAccessLocalPreferences.java b/src/com/android/documentsui/prefs/ScopedAccessLocalPreferences.java deleted file mode 100644 index 0bdd484dd..000000000 --- a/src/com/android/documentsui/prefs/ScopedAccessLocalPreferences.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2017 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.android.documentsui.prefs; - -import android.content.Context; -import android.content.SharedPreferences; -import android.content.SharedPreferences.Editor; -import android.preference.PreferenceManager; - -/** - * Methods for accessing the local preferences with regards to scoped directory access. - * TODO(b/111892460): Delete this class after Q is released. - */ -@Deprecated -public class ScopedAccessLocalPreferences { - - private static final String TAG = "ScopedAccessLocalPreferences"; - - private static SharedPreferences getPrefs(Context context) { - return PreferenceManager.getDefaultSharedPreferences(context); - } - - /** Clears all scoped directory access preferences. */ - public static void clearScopedAccessPreferences(Context context) { - final String keySubstring = "|"; - final SharedPreferences prefs = getPrefs(context); - Editor editor = null; - for (final String key : prefs.getAll().keySet()) { - if (key.contains(keySubstring)) { - if (editor == null) { - editor = prefs.edit(); - } - editor.remove(key); - } - } - if (editor != null) { - editor.apply(); - } - } -} diff --git a/src/com/android/documentsui/prefs/ScopedPreferences.java b/src/com/android/documentsui/prefs/ScopedPreferences.java deleted file mode 100644 index a0db76ef7..000000000 --- a/src/com/android/documentsui/prefs/ScopedPreferences.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.android.documentsui.prefs; - -import android.content.Context; -import android.content.SharedPreferences; -import android.preference.PreferenceManager; -import android.text.TextUtils; - -import com.android.documentsui.R; - -/** - * Provides an interface (and runtime implementation) for preferences that are - * scoped (presumably to an activity). This eliminates the need to pass - * scoping values into {@link LocalPreferences}, as well as eliminates - * the static-coupling to {@link LocalPreferences} increasing testability. - */ -public interface ScopedPreferences { - - String INCLUDE_DEVICE_ROOT = "includeDeviceRoot"; - String RECORD_SEARCH = "recordSearch"; - - boolean getShowDeviceRoot(); - void setShowDeviceRoot(boolean display); - - /** - * Get boolean preferences values of recordSearch. - */ - boolean isRecordSearch(); - - /** - * Set boolean preferences values of recordSearch. - */ - void setRecordSearch(boolean show); - - /** - * @param scope An arbitrary string representitive of the scope - * for prefs that are set using this object. - */ - public static ScopedPreferences create(Context context, String scope) { - return new RuntimeScopedPreferences(context, - PreferenceManager.getDefaultSharedPreferences(context), scope); - } - - static final class RuntimeScopedPreferences implements ScopedPreferences { - - private final SharedPreferences mSharedPrefs; - private final String mScope; - private final boolean mDefaultShowDeviceRoot; - - private RuntimeScopedPreferences(Context context, SharedPreferences sharedPrefs, - String scope) { - assert(!TextUtils.isEmpty(scope)); - - mSharedPrefs = sharedPrefs; - mScope = scope; - mDefaultShowDeviceRoot = context.getResources() - .getBoolean(R.bool.config_default_show_device_root); - } - - @Override - public boolean getShowDeviceRoot() { - return mSharedPrefs.getBoolean(INCLUDE_DEVICE_ROOT, mDefaultShowDeviceRoot); - } - - @Override - public void setShowDeviceRoot(boolean display) { - mSharedPrefs.edit().putBoolean(INCLUDE_DEVICE_ROOT, display).apply(); - } - - @Override - public boolean isRecordSearch() { - return mSharedPrefs.getBoolean(RECORD_SEARCH, true); - } - - @Override - public void setRecordSearch(boolean show) { - mSharedPrefs.edit().putBoolean(RECORD_SEARCH, show).apply(); - } - } - - static boolean shouldBackup(String s) { - return INCLUDE_DEVICE_ROOT.equals(s); - } -} diff --git a/src/com/android/documentsui/queries/SearchViewManager.java b/src/com/android/documentsui/queries/SearchViewManager.java index f74aa8ace..be3238394 100644 --- a/src/com/android/documentsui/queries/SearchViewManager.java +++ b/src/com/android/documentsui/queries/SearchViewManager.java @@ -37,7 +37,6 @@ import android.view.View.OnFocusChangeListener; import android.view.ViewGroup; import androidx.annotation.GuardedBy; -import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; import androidx.appcompat.widget.SearchView; @@ -55,7 +54,6 @@ import com.android.documentsui.base.State; import java.util.Timer; import java.util.TimerTask; -import java.util.function.BooleanSupplier; /** * Manages searching UI behavior. @@ -74,7 +72,6 @@ public class SearchViewManager implements private final SearchChipViewManager mChipViewManager; private final Timer mTimer; private final Handler mUiHandler; - private final BooleanSupplier mRecordSearchSupplier; private final Object mSearchLock; @GuardedBy("mSearchLock") @@ -97,10 +94,9 @@ public class SearchViewManager implements SearchManagerListener listener, EventHandler<String> commandProcessor, ViewGroup chipGroup, - @Nullable Bundle savedState, - @NonNull BooleanSupplier recordSearchSupplier) { + @Nullable Bundle savedState) { this(listener, commandProcessor, new SearchChipViewManager(chipGroup), savedState, - recordSearchSupplier, new Timer(), new Handler(Looper.getMainLooper())); + new Timer(), new Handler(Looper.getMainLooper())); } @VisibleForTesting @@ -109,7 +105,6 @@ public class SearchViewManager implements EventHandler<String> commandProcessor, SearchChipViewManager chipViewManager, @Nullable Bundle savedState, - @NonNull BooleanSupplier recordSearchSupplier, Timer timer, Handler handler) { assert (listener != null); @@ -122,7 +117,6 @@ public class SearchViewManager implements mUiHandler = handler; mChipViewManager = chipViewManager; mChipViewManager.setSearchChipViewManagerListener(this::onChipCheckedStateChanged); - mRecordSearchSupplier = recordSearchSupplier; if (savedState != null) { mCurrentSearch = savedState.getString(Shared.EXTRA_QUERY); @@ -540,7 +534,7 @@ public class SearchViewManager implements * Record current search for history. */ public void recordHistory() { - if (TextUtils.isEmpty(mCurrentSearch) || !mRecordSearchSupplier.getAsBoolean()) { + if (TextUtils.isEmpty(mCurrentSearch)) { return; } diff --git a/tests/common/com/android/documentsui/testing/TestEnv.java b/tests/common/com/android/documentsui/testing/TestEnv.java index 15c905397..8f55dde6a 100644 --- a/tests/common/com/android/documentsui/testing/TestEnv.java +++ b/tests/common/com/android/documentsui/testing/TestEnv.java @@ -96,7 +96,6 @@ public class TestEnv { injector = new Injector( features, new TestActivityConfig(), - null, // ScopedPreferences are not currently required for tests null, // MessageBuilder is not currently required for tests dialogs, new TestFileTypeLookup(), diff --git a/tests/common/com/android/documentsui/testing/TestScopedPreferences.java b/tests/common/com/android/documentsui/testing/TestScopedPreferences.java deleted file mode 100644 index 2ef79c4d4..000000000 --- a/tests/common/com/android/documentsui/testing/TestScopedPreferences.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2017 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.documentsui.testing; - -import com.android.documentsui.prefs.ScopedPreferences; - -/** - * Test copy of ScopedPreferences, everything default to false. - */ -public class TestScopedPreferences implements ScopedPreferences { - - private boolean mShowDeviceRoot; - private boolean mIsRecordSearch; - - @Override - public boolean getShowDeviceRoot() { - return mShowDeviceRoot; - } - - @Override - public void setShowDeviceRoot(boolean display) { - mShowDeviceRoot = display; - } - - @Override - public boolean isRecordSearch() { - return mIsRecordSearch; - } - - @Override - public void setRecordSearch(boolean show) { - mIsRecordSearch = show; - } -} diff --git a/tests/common/com/android/documentsui/testing/TestSearchViewManager.java b/tests/common/com/android/documentsui/testing/TestSearchViewManager.java index f5cde8aa0..dbc5c4480 100644 --- a/tests/common/com/android/documentsui/testing/TestSearchViewManager.java +++ b/tests/common/com/android/documentsui/testing/TestSearchViewManager.java @@ -66,7 +66,7 @@ public class TestSearchViewManager extends SearchViewManager { } }, new CommandInterceptor(new TestFeatures()), mock(ViewGroup.class), - null /* savedState */, () -> true /* recordSearchSupplier */); + null /* savedState */); } @Override diff --git a/tests/unit/com/android/documentsui/files/MenuManagerTest.java b/tests/unit/com/android/documentsui/files/MenuManagerTest.java index 2c1b5ac45..7e9422668 100644 --- a/tests/unit/com/android/documentsui/files/MenuManagerTest.java +++ b/tests/unit/com/android/documentsui/files/MenuManagerTest.java @@ -41,7 +41,6 @@ import com.android.documentsui.testing.TestFeatures; import com.android.documentsui.testing.TestMenu; import com.android.documentsui.testing.TestMenuInflater; import com.android.documentsui.testing.TestMenuItem; -import com.android.documentsui.testing.TestScopedPreferences; import com.android.documentsui.testing.TestSearchViewManager; import com.android.documentsui.testing.TestSelectionDetails; @@ -113,7 +112,6 @@ public final class MenuManagerTest { private TestSelectionDetails selectionDetails; private TestDirectoryDetails dirDetails; private TestSearchViewManager testSearchManager; - private TestScopedPreferences preferences; private RootInfo testRootInfo; private DocumentInfo testDocInfo; private State state = new State(); @@ -189,7 +187,6 @@ public final class MenuManagerTest { selectionDetails = new TestSelectionDetails(); dirDetails = new TestDirectoryDetails(); testSearchManager = new TestSearchViewManager(); - preferences = new TestScopedPreferences(); selectionManager = SelectionHelpers.createTestInstance(TestData.create(1)); selectionManager.select("0"); diff --git a/tests/unit/com/android/documentsui/prefs/PreferencesMonitorTest.java b/tests/unit/com/android/documentsui/prefs/PreferencesMonitorTest.java index 1ff346451..512e479eb 100644 --- a/tests/unit/com/android/documentsui/prefs/PreferencesMonitorTest.java +++ b/tests/unit/com/android/documentsui/prefs/PreferencesMonitorTest.java @@ -35,6 +35,8 @@ import java.util.concurrent.TimeUnit; @SmallTest public class PreferencesMonitorTest { + private static final String LOCAL_PREFERENCE = "rootViewMode-testRoot"; + private SharedPreferences mPrefs; private PreferencesMonitor mMonitor; private TestConsumer<String> mConsumer; @@ -54,9 +56,9 @@ public class PreferencesMonitorTest { @Test public void testReportsChangesToListener() throws Exception { - mPrefs.edit().putBoolean(ScopedPreferences.INCLUDE_DEVICE_ROOT, true).apply(); - // internally the monitor waits for notification of changes. - mConsumer.waitForCall(100, TimeUnit.MILLISECONDS); - mConsumer.assertLastArgument(ScopedPreferences.INCLUDE_DEVICE_ROOT); + mPrefs.edit().putInt(LOCAL_PREFERENCE, 1).apply(); + // internally the monitor waits for notification of changes. + mConsumer.waitForCall(100, TimeUnit.MILLISECONDS); + mConsumer.assertLastArgument(LOCAL_PREFERENCE); } } diff --git a/tests/unit/com/android/documentsui/prefs/PrefsBackupHelperTest.java b/tests/unit/com/android/documentsui/prefs/PrefsBackupHelperTest.java index 08c72c539..f773ba60d 100644 --- a/tests/unit/com/android/documentsui/prefs/PrefsBackupHelperTest.java +++ b/tests/unit/com/android/documentsui/prefs/PrefsBackupHelperTest.java @@ -43,7 +43,6 @@ public class PrefsBackupHelperTest { private static final String LOCAL_PREFERENCE_1 = "rootViewMode-validPreference1"; private static final String LOCAL_PREFERENCE_2 = "rootViewMode-validPreference2"; - private static final String SCOPED_PREFERENCE = "includeDeviceRoot"; private static final String NON_BACKUP_PREFERENCE = "notBackup-invalidPreference"; private SharedPreferences mDefaultPrefs; @@ -78,15 +77,6 @@ public class PrefsBackupHelperTest { } @Test - public void testPrepareBackupFile_BackupScopedPreferences() { - mDefaultPrefs.edit().putBoolean(SCOPED_PREFERENCE, true).commit(); - - mPrefsBackupHelper.getBackupPreferences(mBackupPrefs); - - assertEquals(mBackupPrefs.getBoolean(SCOPED_PREFERENCE, false), true); - } - - @Test public void testPrepareBackupFile_BackupNotInterestedPreferences() { mDefaultPrefs.edit().putBoolean(NON_BACKUP_PREFERENCE, true).commit(); @@ -120,15 +110,6 @@ public class PrefsBackupHelperTest { } @Test - public void testRestorePreferences_RestoreScopedPreferences() { - mBackupPrefs.edit().putBoolean(SCOPED_PREFERENCE, true).commit(); - - mPrefsBackupHelper.putBackupPreferences(mBackupPrefs); - - assertEquals(mDefaultPrefs.getBoolean(SCOPED_PREFERENCE, false), true); - } - - @Test public void testEndToEnd() { // Simulating an end to end backup & restore process. At the begining, all preferences are // stored in the default shared preferences file, includes preferences that we don't want @@ -145,7 +126,6 @@ public class PrefsBackupHelperTest { // Set preferences to the default file, includes preferences that are not backed up. editor.putInt(LOCAL_PREFERENCE_1, 1); editor.putInt(LOCAL_PREFERENCE_2, 2); - editor.putBoolean(SCOPED_PREFERENCE, true); editor.putBoolean(NON_BACKUP_PREFERENCE, true); editor.commit(); @@ -165,7 +145,6 @@ public class PrefsBackupHelperTest { // Check all preferences are correctly restored. assertEquals(mDefaultPrefs.getInt(LOCAL_PREFERENCE_1, 0), 1); assertEquals(mDefaultPrefs.getInt(LOCAL_PREFERENCE_2, 0), 2); - assertEquals(mDefaultPrefs.getBoolean(SCOPED_PREFERENCE, false), true); assertFalse(mDefaultPrefs.contains(NON_BACKUP_PREFERENCE)); } diff --git a/tests/unit/com/android/documentsui/queries/SearchViewManagerTest.java b/tests/unit/com/android/documentsui/queries/SearchViewManagerTest.java index 265739016..f78cb1828 100644 --- a/tests/unit/com/android/documentsui/queries/SearchViewManagerTest.java +++ b/tests/unit/com/android/documentsui/queries/SearchViewManagerTest.java @@ -26,7 +26,6 @@ import static com.android.documentsui.base.State.ACTION_GET_CONTENT; import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertFalse; -import static junit.framework.Assert.assertNull; import static junit.framework.Assert.assertTrue; import static org.mockito.Mockito.mock; @@ -43,7 +42,6 @@ import android.text.TextUtils; import android.view.View; import android.view.ViewGroup; -import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.test.filters.SmallTest; import androidx.test.runner.AndroidJUnit4; @@ -71,7 +69,6 @@ import java.util.HashSet; import java.util.Set; import java.util.Timer; import java.util.TimerTask; -import java.util.function.BooleanSupplier; @RunWith(AndroidJUnit4.class) @SmallTest @@ -86,7 +83,6 @@ public final class SearchViewManagerTest { private SearchChipViewManager mSearchChipViewManager; private boolean mListenerOnSearchChangedCalled; - private boolean mRecordSearch; @Before public void setUp() { @@ -123,11 +119,8 @@ public final class SearchViewManagerTest { ViewGroup chipGroup = mock(ViewGroup.class); mSearchChipViewManager = spy(new SearchChipViewManager(chipGroup)); - BooleanSupplier supplier = () -> mRecordSearch; - mRecordSearch = true; mSearchViewManager = new TestableSearchViewManager(searchListener, mTestEventHandler, - mSearchChipViewManager, null /* savedState */, supplier, - mTestTimer, mTestHandler); + mSearchChipViewManager, null /* savedState */, mTestTimer, mTestHandler); mTestMenu = TestMenu.create(); mSearchMenuItem = mTestMenu.findItem(R.id.option_menu_search); @@ -144,11 +137,9 @@ public final class SearchViewManagerTest { EventHandler<String> commandProcessor, SearchChipViewManager chipViewManager, @Nullable Bundle savedState, - @NonNull BooleanSupplier pauseHistorySupplier, Timer timer, Handler handler) { - super(listener, commandProcessor, chipViewManager, savedState, - pauseHistorySupplier, timer, handler); + super(listener, commandProcessor, chipViewManager, savedState, timer, handler); } @Override @@ -331,16 +322,6 @@ public final class SearchViewManagerTest { } @Test - public void testHistoryRecorded_pauseRecord() { - mRecordSearch = false; - - mSearchViewManager.onClick(null); - mSearchViewManager.onQueryTextSubmit("q"); - - assertNull(mSearchViewManager.getRecordedHistory()); - } - - @Test public void testHistoryRecorded_skipWhenNoSearchString() { mSearchViewManager.recordHistory(); |