Merge "Fix long click the Color Inversion tile can not link to its settings page." into sc-v2-dev
This commit is contained in:
@@ -378,6 +378,21 @@ public final class Settings {
|
||||
public static final String ACTION_REDUCE_BRIGHT_COLORS_SETTINGS =
|
||||
"android.settings.REDUCE_BRIGHT_COLORS_SETTINGS";
|
||||
|
||||
/**
|
||||
* Activity Action: Show settings to allow configuration of Color inversion.
|
||||
* <p>
|
||||
* In some cases, a matching Activity may not exist, so ensure you
|
||||
* safeguard against this.
|
||||
* <p>
|
||||
* Input: Nothing.
|
||||
* <p>
|
||||
* Output: Nothing.
|
||||
* @hide
|
||||
*/
|
||||
@SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
|
||||
public static final String ACTION_COLOR_INVERSION_SETTINGS =
|
||||
"android.settings.COLOR_INVERSION_SETTINGS";
|
||||
|
||||
/**
|
||||
* Activity Action: Show settings to control access to usage information.
|
||||
* <p>
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package com.android.systemui.qs.tiles;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.provider.Settings;
|
||||
@@ -110,11 +109,7 @@ public class ColorInversionTile extends QSTileImpl<BooleanState> {
|
||||
|
||||
@Override
|
||||
public Intent getLongClickIntent() {
|
||||
Intent intent = new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS);
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(EXTRA_FRAGMENT_ARGS_KEY, COLOR_INVERSION_PREFERENCE_KEY);
|
||||
intent.putExtra(EXTRA_SHOW_FRAGMENT_ARGS_KEY, bundle);
|
||||
return intent;
|
||||
return new Intent(Settings.ACTION_COLOR_INVERSION_SETTINGS);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Copyright (C) 2021 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.systemui.qs.tiles;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Handler;
|
||||
import android.provider.Settings;
|
||||
import android.testing.AndroidTestingRunner;
|
||||
import android.testing.TestableLooper;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
import com.android.internal.logging.MetricsLogger;
|
||||
import com.android.internal.logging.UiEventLogger;
|
||||
import com.android.systemui.SysuiTestCase;
|
||||
import com.android.systemui.classifier.FalsingManagerFake;
|
||||
import com.android.systemui.plugins.ActivityStarter;
|
||||
import com.android.systemui.plugins.statusbar.StatusBarStateController;
|
||||
import com.android.systemui.qs.QSTileHost;
|
||||
import com.android.systemui.qs.logging.QSLogger;
|
||||
import com.android.systemui.settings.UserTracker;
|
||||
import com.android.systemui.util.settings.FakeSettings;
|
||||
import com.android.systemui.util.settings.SecureSettings;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
@RunWith(AndroidTestingRunner.class)
|
||||
@TestableLooper.RunWithLooper(setAsMainLooper = true)
|
||||
@SmallTest
|
||||
public class ColorInversionTileTest extends SysuiTestCase {
|
||||
|
||||
@Mock
|
||||
private QSTileHost mHost;
|
||||
@Mock
|
||||
private MetricsLogger mMetricsLogger;
|
||||
@Mock
|
||||
private StatusBarStateController mStatusBarStateController;
|
||||
@Mock
|
||||
private ActivityStarter mActivityStarter;
|
||||
@Mock
|
||||
private QSLogger mQSLogger;
|
||||
@Mock
|
||||
private UiEventLogger mUiEventLogger;
|
||||
@Mock
|
||||
private UserTracker mUserTracker;
|
||||
|
||||
private TestableLooper mTestableLooper;
|
||||
private SecureSettings mSecureSettings;
|
||||
private ColorInversionTile mTile;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
|
||||
mSecureSettings = new FakeSettings();
|
||||
mTestableLooper = TestableLooper.get(this);
|
||||
|
||||
when(mHost.getContext()).thenReturn(mContext);
|
||||
when(mHost.getUiEventLogger()).thenReturn(mUiEventLogger);
|
||||
|
||||
mTile = new ColorInversionTile(
|
||||
mHost,
|
||||
mTestableLooper.getLooper(),
|
||||
new Handler(mTestableLooper.getLooper()),
|
||||
new FalsingManagerFake(),
|
||||
mMetricsLogger,
|
||||
mStatusBarStateController,
|
||||
mActivityStarter,
|
||||
mQSLogger,
|
||||
mUserTracker,
|
||||
mSecureSettings
|
||||
);
|
||||
|
||||
mTile.initialize();
|
||||
mTestableLooper.processAllMessages();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void longClick_expectedAction() {
|
||||
final ArgumentCaptor<Intent> IntentCaptor = ArgumentCaptor.forClass(Intent.class);
|
||||
|
||||
mTile.longClick(/* view= */ null);
|
||||
mTestableLooper.processAllMessages();
|
||||
|
||||
verify(mActivityStarter).postStartActivityDismissingKeyguard(IntentCaptor.capture(),
|
||||
anyInt(), any());
|
||||
assertThat(IntentCaptor.getValue().getAction()).isEqualTo(
|
||||
Settings.ACTION_COLOR_INVERSION_SETTINGS);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user