Merge "Add option for settings to push to a device index" into pi-dev am: f9c6bc59ae
am: 5411c21dde
Change-Id: I48ecc5d6e892a8662d5f0ad019579d6d2396c18a
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.settings.search;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.atLeastOnce;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.Robolectric;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
public class DeviceIndexFeatureProviderTest {
|
||||
|
||||
private DeviceIndexFeatureProvider mProvider;
|
||||
private Activity mActivity;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
FakeFeatureFactory.setupForTest();
|
||||
mActivity = Robolectric.buildActivity(Activity.class).create().visible().get();
|
||||
mProvider = spy(new DeviceIndexFeatureProviderImpl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void verifyDisabled() {
|
||||
when(mProvider.isIndexingEnabled()).thenReturn(false);
|
||||
|
||||
mProvider.updateIndex(mActivity, false);
|
||||
verify(mProvider, never()).index(any(), any(), any(), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void verifyIndexing() {
|
||||
when(mProvider.isIndexingEnabled()).thenReturn(true);
|
||||
|
||||
mProvider.updateIndex(mActivity, false);
|
||||
verify(mProvider, atLeastOnce()).index(any(), any(), any(), any());
|
||||
}
|
||||
}
|
@@ -33,6 +33,7 @@ import com.android.settings.localepicker.LocaleFeatureProvider;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.overlay.SupportFeatureProvider;
|
||||
import com.android.settings.overlay.SurveyFeatureProvider;
|
||||
import com.android.settings.search.DeviceIndexFeatureProvider;
|
||||
import com.android.settings.search.SearchFeatureProvider;
|
||||
import com.android.settings.security.SecurityFeatureProvider;
|
||||
import com.android.settings.slices.SlicesFeatureProvider;
|
||||
@@ -63,6 +64,7 @@ public class FakeFeatureFactory extends FeatureFactory {
|
||||
public final SlicesFeatureProvider slicesFeatureProvider;
|
||||
public SearchFeatureProvider searchFeatureProvider;
|
||||
public final AccountFeatureProvider mAccountFeatureProvider;
|
||||
public final DeviceIndexFeatureProvider deviceIndexFeatureProvider;
|
||||
|
||||
/**
|
||||
* Call this in {@code @Before} method of the test class to use fake factory.
|
||||
@@ -101,6 +103,7 @@ public class FakeFeatureFactory extends FeatureFactory {
|
||||
bluetoothFeatureProvider = mock(BluetoothFeatureProvider.class);
|
||||
slicesFeatureProvider = mock(SlicesFeatureProvider.class);
|
||||
mAccountFeatureProvider = mock(AccountFeatureProvider.class);
|
||||
deviceIndexFeatureProvider = mock(DeviceIndexFeatureProvider.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -182,4 +185,9 @@ public class FakeFeatureFactory extends FeatureFactory {
|
||||
public AccountFeatureProvider getAccountFeatureProvider() {
|
||||
return mAccountFeatureProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceIndexFeatureProvider getDeviceIndexFeatureProvider() {
|
||||
return deviceIndexFeatureProvider;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user