Revert^2 "8/N Remove View Injection from KeyguardMessageArea"
dd7312c20a
Change-Id: Idca486311380b48e1f0808c8d08cfce46c929473
This commit is contained in:
@@ -81,6 +81,12 @@ public abstract class KeyguardAbsKeyInputViewController<T extends KeyguardAbsKey
|
||||
|
||||
abstract void resetState();
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
mMessageAreaController.init();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onViewAttached() {
|
||||
mView.setKeyDownListener(mKeyDownListener);
|
||||
|
||||
@@ -39,7 +39,6 @@ import com.android.systemui.Dependency;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.navigationbar.NavigationBarController;
|
||||
import com.android.systemui.navigationbar.NavigationBarView;
|
||||
import com.android.systemui.util.InjectionInflationController;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@@ -49,7 +48,6 @@ public class KeyguardDisplayManager {
|
||||
|
||||
private final MediaRouter mMediaRouter;
|
||||
private final DisplayManager mDisplayService;
|
||||
private final InjectionInflationController mInjectableInflater;
|
||||
private final KeyguardStatusViewComponent.Factory mKeyguardStatusViewComponentFactory;
|
||||
private final Context mContext;
|
||||
|
||||
@@ -92,10 +90,8 @@ public class KeyguardDisplayManager {
|
||||
|
||||
@Inject
|
||||
public KeyguardDisplayManager(Context context,
|
||||
InjectionInflationController injectableInflater,
|
||||
KeyguardStatusViewComponent.Factory keyguardStatusViewComponentFactory) {
|
||||
mContext = context;
|
||||
mInjectableInflater = injectableInflater;
|
||||
mKeyguardStatusViewComponentFactory = keyguardStatusViewComponentFactory;
|
||||
mMediaRouter = mContext.getSystemService(MediaRouter.class);
|
||||
mDisplayService = mContext.getSystemService(DisplayManager.class);
|
||||
@@ -131,8 +127,7 @@ public class KeyguardDisplayManager {
|
||||
Presentation presentation = mPresentations.get(displayId);
|
||||
if (presentation == null) {
|
||||
final Presentation newPresentation = new KeyguardPresentation(mContext, display,
|
||||
mKeyguardStatusViewComponentFactory,
|
||||
mInjectableInflater.injectable(LayoutInflater.from(mContext)));
|
||||
mKeyguardStatusViewComponentFactory, LayoutInflater.from(mContext));
|
||||
newPresentation.setOnDismissListener(dialog -> {
|
||||
if (newPresentation.equals(mPresentations.get(displayId))) {
|
||||
mPresentations.remove(displayId);
|
||||
@@ -250,7 +245,7 @@ public class KeyguardDisplayManager {
|
||||
private static final int VIDEO_SAFE_REGION = 80; // Percentage of display width & height
|
||||
private static final int MOVE_CLOCK_TIMEOUT = 10000; // 10s
|
||||
private final KeyguardStatusViewComponent.Factory mKeyguardStatusViewComponentFactory;
|
||||
private final LayoutInflater mInjectableLayoutInflater;
|
||||
private final LayoutInflater mLayoutInflater;
|
||||
private KeyguardClockSwitchController mKeyguardClockSwitchController;
|
||||
private View mClock;
|
||||
private int mUsableWidth;
|
||||
@@ -270,10 +265,10 @@ public class KeyguardDisplayManager {
|
||||
|
||||
KeyguardPresentation(Context context, Display display,
|
||||
KeyguardStatusViewComponent.Factory keyguardStatusViewComponentFactory,
|
||||
LayoutInflater injectionLayoutInflater) {
|
||||
LayoutInflater layoutInflater) {
|
||||
super(context, display, R.style.Theme_SystemUI_KeyguardPresentation);
|
||||
mKeyguardStatusViewComponentFactory = keyguardStatusViewComponentFactory;
|
||||
mInjectableLayoutInflater = injectionLayoutInflater;
|
||||
mLayoutInflater = layoutInflater;
|
||||
getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
|
||||
setCancelable(false);
|
||||
}
|
||||
@@ -299,7 +294,7 @@ public class KeyguardDisplayManager {
|
||||
mMarginLeft = (100 - VIDEO_SAFE_REGION) * p.x / 200;
|
||||
mMarginTop = (100 - VIDEO_SAFE_REGION) * p.y / 200;
|
||||
|
||||
setContentView(mInjectableLayoutInflater.inflate(R.layout.keyguard_presentation, null));
|
||||
setContentView(mLayoutInflater.inflate(R.layout.keyguard_presentation, null));
|
||||
|
||||
// Logic to make the lock screen fullscreen
|
||||
getWindow().getDecorView().setSystemUiVisibility(
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
package com.android.keyguard;
|
||||
|
||||
import static com.android.systemui.util.InjectionInflationController.VIEW_CONTEXT;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.TypedArray;
|
||||
@@ -31,20 +29,14 @@ import android.util.TypedValue;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.systemui.Dependency;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.statusbar.policy.ConfigurationController;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
/***
|
||||
* Manages a number of views inside of the given layout. See below for a list of widgets.
|
||||
*/
|
||||
public class KeyguardMessageArea extends TextView implements SecurityMessageDisplay,
|
||||
ConfigurationController.ConfigurationListener {
|
||||
public class KeyguardMessageArea extends TextView implements SecurityMessageDisplay {
|
||||
/** Handler token posted with accessibility announcement runnables. */
|
||||
private static final Object ANNOUNCE_TOKEN = new Object();
|
||||
|
||||
@@ -56,71 +48,26 @@ public class KeyguardMessageArea extends TextView implements SecurityMessageDisp
|
||||
private static final int DEFAULT_COLOR = -1;
|
||||
|
||||
private final Handler mHandler;
|
||||
private final ConfigurationController mConfigurationController;
|
||||
|
||||
private ColorStateList mDefaultColorState;
|
||||
private CharSequence mMessage;
|
||||
private ColorStateList mNextMessageColorState = ColorStateList.valueOf(DEFAULT_COLOR);
|
||||
private boolean mBouncerVisible;
|
||||
|
||||
private KeyguardUpdateMonitorCallback mInfoCallback = new KeyguardUpdateMonitorCallback() {
|
||||
public void onFinishedGoingToSleep(int why) {
|
||||
setSelected(false);
|
||||
}
|
||||
|
||||
public void onStartedWakingUp() {
|
||||
setSelected(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onKeyguardBouncerChanged(boolean bouncer) {
|
||||
mBouncerVisible = bouncer;
|
||||
update();
|
||||
}
|
||||
};
|
||||
|
||||
public KeyguardMessageArea(Context context) {
|
||||
super(context, null);
|
||||
throw new IllegalStateException("This constructor should never be invoked");
|
||||
}
|
||||
|
||||
@Inject
|
||||
public KeyguardMessageArea(@Named(VIEW_CONTEXT) Context context, AttributeSet attrs,
|
||||
ConfigurationController configurationController) {
|
||||
this(context, attrs, Dependency.get(KeyguardUpdateMonitor.class), configurationController);
|
||||
}
|
||||
|
||||
public KeyguardMessageArea(Context context, AttributeSet attrs, KeyguardUpdateMonitor monitor,
|
||||
ConfigurationController configurationController) {
|
||||
public KeyguardMessageArea(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
setLayerType(LAYER_TYPE_HARDWARE, null); // work around nested unclipped SaveLayer bug
|
||||
|
||||
monitor.registerCallback(mInfoCallback);
|
||||
mHandler = new Handler(Looper.myLooper());
|
||||
mConfigurationController = configurationController;
|
||||
onThemeChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
mConfigurationController.addCallback(this);
|
||||
onThemeChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
mConfigurationController.removeCallback(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNextMessageColor(ColorStateList colorState) {
|
||||
mNextMessageColorState = colorState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onThemeChanged() {
|
||||
void onThemeChanged() {
|
||||
TypedArray array = mContext.obtainStyledAttributes(new int[] {
|
||||
R.attr.wallpaperTextColor
|
||||
});
|
||||
@@ -130,8 +77,7 @@ public class KeyguardMessageArea extends TextView implements SecurityMessageDisp
|
||||
update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDensityOrFontScaleChanged() {
|
||||
void onDensityOrFontScaleChanged() {
|
||||
TypedArray array = mContext.obtainStyledAttributes(R.style.Keyguard_TextView, new int[] {
|
||||
android.R.attr.textSize
|
||||
});
|
||||
@@ -177,12 +123,6 @@ public class KeyguardMessageArea extends TextView implements SecurityMessageDisp
|
||||
return messageArea;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishInflate() {
|
||||
boolean shouldMarquee = Dependency.get(KeyguardUpdateMonitor.class).isDeviceInteractive();
|
||||
setSelected(shouldMarquee); // This is required to ensure marquee works
|
||||
}
|
||||
|
||||
private void securityMessageChanged(CharSequence message) {
|
||||
mMessage = message;
|
||||
update();
|
||||
@@ -196,7 +136,7 @@ public class KeyguardMessageArea extends TextView implements SecurityMessageDisp
|
||||
update();
|
||||
}
|
||||
|
||||
private void update() {
|
||||
void update() {
|
||||
CharSequence status = mMessage;
|
||||
setVisibility(TextUtils.isEmpty(status) || !mBouncerVisible ? INVISIBLE : VISIBLE);
|
||||
setText(status);
|
||||
@@ -208,6 +148,9 @@ public class KeyguardMessageArea extends TextView implements SecurityMessageDisp
|
||||
setTextColor(colorState);
|
||||
}
|
||||
|
||||
public void setBouncerVisible(boolean bouncerVisible) {
|
||||
mBouncerVisible = bouncerVisible;
|
||||
}
|
||||
|
||||
/**
|
||||
* Runnable used to delay accessibility announcements.
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.android.keyguard;
|
||||
import android.content.res.ColorStateList;
|
||||
|
||||
import com.android.systemui.statusbar.policy.ConfigurationController;
|
||||
import com.android.systemui.statusbar.policy.ConfigurationController.ConfigurationListener;
|
||||
import com.android.systemui.util.ViewController;
|
||||
|
||||
import javax.inject.Inject;
|
||||
@@ -28,6 +29,35 @@ public class KeyguardMessageAreaController extends ViewController<KeyguardMessag
|
||||
private final KeyguardUpdateMonitor mKeyguardUpdateMonitor;
|
||||
private final ConfigurationController mConfigurationController;
|
||||
|
||||
|
||||
private KeyguardUpdateMonitorCallback mInfoCallback = new KeyguardUpdateMonitorCallback() {
|
||||
public void onFinishedGoingToSleep(int why) {
|
||||
mView.setSelected(false);
|
||||
}
|
||||
|
||||
public void onStartedWakingUp() {
|
||||
mView.setSelected(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onKeyguardBouncerChanged(boolean bouncer) {
|
||||
mView.setBouncerVisible(bouncer);
|
||||
mView.update();
|
||||
}
|
||||
};
|
||||
|
||||
private ConfigurationListener mConfigurationListener = new ConfigurationListener() {
|
||||
@Override
|
||||
public void onThemeChanged() {
|
||||
mView.onThemeChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDensityOrFontScaleChanged() {
|
||||
mView.onDensityOrFontScaleChanged();
|
||||
}
|
||||
};
|
||||
|
||||
private KeyguardMessageAreaController(KeyguardMessageArea view,
|
||||
KeyguardUpdateMonitor keyguardUpdateMonitor,
|
||||
ConfigurationController configurationController) {
|
||||
@@ -39,10 +69,16 @@ public class KeyguardMessageAreaController extends ViewController<KeyguardMessag
|
||||
|
||||
@Override
|
||||
protected void onViewAttached() {
|
||||
mConfigurationController.addCallback(mConfigurationListener);
|
||||
mKeyguardUpdateMonitor.registerCallback(mInfoCallback);
|
||||
mView.setSelected(mKeyguardUpdateMonitor.isDeviceInteractive());
|
||||
mView.onThemeChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onViewDetached() {
|
||||
mConfigurationController.removeCallback(mConfigurationListener);
|
||||
mKeyguardUpdateMonitor.removeCallback(mInfoCallback);
|
||||
}
|
||||
|
||||
public void setMessage(CharSequence s) {
|
||||
|
||||
@@ -190,6 +190,12 @@ public class KeyguardPatternViewController
|
||||
mLockPatternView = mView.findViewById(R.id.lockPatternView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
mMessageAreaController.init();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onViewAttached() {
|
||||
mLockPatternView.setOnPatternListener(new UnlockPatternListener());
|
||||
|
||||
@@ -26,7 +26,6 @@ import com.android.keyguard.KeyguardInputViewController.Factory;
|
||||
import com.android.keyguard.KeyguardSecurityModel.SecurityMode;
|
||||
import com.android.keyguard.dagger.KeyguardBouncerScope;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.util.InjectionInflationController;
|
||||
import com.android.systemui.util.ViewController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -51,11 +50,10 @@ public class KeyguardSecurityViewFlipperController
|
||||
@Inject
|
||||
protected KeyguardSecurityViewFlipperController(KeyguardSecurityViewFlipper view,
|
||||
LayoutInflater layoutInflater,
|
||||
InjectionInflationController injectionInflationController,
|
||||
KeyguardInputViewController.Factory keyguardSecurityViewControllerFactory) {
|
||||
super(view);
|
||||
mKeyguardSecurityViewControllerFactory = keyguardSecurityViewControllerFactory;
|
||||
mLayoutInflater = injectionInflationController.injectable(layoutInflater);
|
||||
mLayoutInflater = layoutInflater;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,7 +23,6 @@ import android.view.InflateException;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
||||
import com.android.keyguard.KeyguardMessageArea;
|
||||
import com.android.systemui.dagger.SysUISingleton;
|
||||
import com.android.systemui.qs.QSFooterImpl;
|
||||
import com.android.systemui.qs.QSPanel;
|
||||
@@ -107,11 +106,6 @@ public class InjectionInflationController {
|
||||
*/
|
||||
NotificationStackScrollLayout createNotificationStackScrollLayout();
|
||||
|
||||
/**
|
||||
* Creates the KeyguardMessageArea.
|
||||
*/
|
||||
KeyguardMessageArea createKeyguardMessageArea();
|
||||
|
||||
/**
|
||||
* Creates the QSPanel.
|
||||
*/
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.android.keyguard;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.reset;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -94,6 +95,7 @@ public class KeyguardAbsKeyInputViewControllerTest extends SysuiTestCase {
|
||||
}
|
||||
};
|
||||
mKeyguardAbsKeyInputViewController.init();
|
||||
reset(mKeyguardMessageAreaController); // Clear out implicit call to init.
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -41,11 +41,9 @@ import android.widget.FrameLayout;
|
||||
import android.widget.TextClock;
|
||||
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.SystemUIFactory;
|
||||
import com.android.systemui.SysuiTestCase;
|
||||
import com.android.systemui.plugins.ClockPlugin;
|
||||
import com.android.systemui.statusbar.StatusBarState;
|
||||
import com.android.systemui.util.InjectionInflationController;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -78,12 +76,7 @@ public class KeyguardClockSwitchTest extends SysuiTestCase {
|
||||
when(mMockKeyguardSliceView.findViewById(R.id.keyguard_status_area))
|
||||
.thenReturn(mMockKeyguardSliceView);
|
||||
|
||||
InjectionInflationController inflationController = new InjectionInflationController(
|
||||
SystemUIFactory.getInstance()
|
||||
.getSysUIComponent()
|
||||
.createViewInstanceCreatorFactory());
|
||||
LayoutInflater layoutInflater = inflationController
|
||||
.injectable(LayoutInflater.from(getContext()));
|
||||
LayoutInflater layoutInflater = LayoutInflater.from(getContext());
|
||||
layoutInflater.setPrivateFactory(new LayoutInflater.Factory2() {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (C) 2020 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.keyguard;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import android.test.suitebuilder.annotation.SmallTest;
|
||||
import android.testing.AndroidTestingRunner;
|
||||
|
||||
import com.android.systemui.SysuiTestCase;
|
||||
import com.android.systemui.statusbar.policy.ConfigurationController;
|
||||
import com.android.systemui.statusbar.policy.ConfigurationController.ConfigurationListener;
|
||||
|
||||
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;
|
||||
|
||||
@SmallTest
|
||||
@RunWith(AndroidTestingRunner.class)
|
||||
public class KeyguardMessageAreaControllerTest extends SysuiTestCase {
|
||||
@Mock
|
||||
private ConfigurationController mConfigurationController;
|
||||
@Mock
|
||||
private KeyguardUpdateMonitor mKeyguardUpdateMonitor;
|
||||
@Mock
|
||||
private KeyguardMessageArea mKeyguardMessageArea;
|
||||
|
||||
private KeyguardMessageAreaController mMessageAreaController;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mMessageAreaController = new KeyguardMessageAreaController.Factory(
|
||||
mKeyguardUpdateMonitor, mConfigurationController).create(mKeyguardMessageArea);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onAttachedToWindow_registersConfigurationCallback() {
|
||||
ArgumentCaptor<ConfigurationListener> configurationListenerArgumentCaptor =
|
||||
ArgumentCaptor.forClass(ConfigurationListener.class);
|
||||
|
||||
mMessageAreaController.onViewAttached();
|
||||
verify(mConfigurationController).addCallback(configurationListenerArgumentCaptor.capture());
|
||||
|
||||
mMessageAreaController.onViewDetached();
|
||||
verify(mConfigurationController).removeCallback(
|
||||
eq(configurationListenerArgumentCaptor.getValue()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onAttachedToWindow_registersKeyguardUpdateMontiorCallback() {
|
||||
ArgumentCaptor<KeyguardUpdateMonitorCallback> keyguardUpdateMonitorCallbackArgumentCaptor =
|
||||
ArgumentCaptor.forClass(KeyguardUpdateMonitorCallback.class);
|
||||
|
||||
mMessageAreaController.onViewAttached();
|
||||
verify(mKeyguardUpdateMonitor).registerCallback(
|
||||
keyguardUpdateMonitorCallbackArgumentCaptor.capture());
|
||||
|
||||
mMessageAreaController.onViewDetached();
|
||||
verify(mKeyguardUpdateMonitor).removeCallback(
|
||||
eq(keyguardUpdateMonitorCallbackArgumentCaptor.getValue()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClearsTextField() {
|
||||
mMessageAreaController.setMessage("");
|
||||
verify(mKeyguardMessageArea).setMessage("");
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2016 The Android Open Source Project
|
||||
* Copyright (C) 2020 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.
|
||||
@@ -11,65 +11,60 @@
|
||||
* 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
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.keyguard;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.test.suitebuilder.annotation.SmallTest;
|
||||
import android.testing.AndroidTestingRunner;
|
||||
import android.testing.TestableLooper.RunWithLooper;
|
||||
import android.view.View;
|
||||
|
||||
import com.android.systemui.SysuiTestCase;
|
||||
import com.android.systemui.statusbar.policy.ConfigurationController;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
@SmallTest
|
||||
@RunWith(AndroidTestingRunner.class)
|
||||
@RunWithLooper
|
||||
public class KeyguardMessageAreaTest extends SysuiTestCase {
|
||||
@Mock
|
||||
private ConfigurationController mConfigurationController;
|
||||
@Mock
|
||||
private KeyguardUpdateMonitor mKeyguardUpdateMonitor;
|
||||
private KeyguardMessageArea mMessageArea;
|
||||
private KeyguardMessageArea mKeyguardMessageArea;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mMessageArea = new KeyguardMessageArea(mContext, null, mKeyguardUpdateMonitor,
|
||||
mConfigurationController);
|
||||
waitForIdleSync();
|
||||
mKeyguardMessageArea = new KeyguardMessageArea(mContext, null);
|
||||
mKeyguardMessageArea.setBouncerVisible(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onAttachedToWindow_registersConfigurationCallback() {
|
||||
mMessageArea.onAttachedToWindow();
|
||||
verify(mConfigurationController).addCallback(eq(mMessageArea));
|
||||
|
||||
mMessageArea.onDetachedFromWindow();
|
||||
verify(mConfigurationController).removeCallback(eq(mMessageArea));
|
||||
public void testShowsTextField() {
|
||||
mKeyguardMessageArea.setVisibility(View.INVISIBLE);
|
||||
mKeyguardMessageArea.setMessage("oobleck");
|
||||
assertThat(mKeyguardMessageArea.getVisibility()).isEqualTo(View.VISIBLE);
|
||||
assertThat(mKeyguardMessageArea.getText()).isEqualTo("oobleck");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void clearFollowedByMessage_keepsMessage() {
|
||||
mMessageArea.setMessage("");
|
||||
mMessageArea.setMessage("test");
|
||||
|
||||
CharSequence[] messageText = new CharSequence[1];
|
||||
messageText[0] = mMessageArea.getText();
|
||||
|
||||
assertEquals("test", messageText[0]);
|
||||
public void testHiddenWhenBouncerHidden() {
|
||||
mKeyguardMessageArea.setBouncerVisible(false);
|
||||
mKeyguardMessageArea.setVisibility(View.INVISIBLE);
|
||||
mKeyguardMessageArea.setMessage("oobleck");
|
||||
assertThat(mKeyguardMessageArea.getVisibility()).isEqualTo(View.INVISIBLE);
|
||||
assertThat(mKeyguardMessageArea.getText()).isEqualTo("oobleck");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClearsTextField() {
|
||||
mKeyguardMessageArea.setVisibility(View.VISIBLE);
|
||||
mKeyguardMessageArea.setMessage("");
|
||||
assertThat(mKeyguardMessageArea.getVisibility()).isEqualTo(View.INVISIBLE);
|
||||
assertThat(mKeyguardMessageArea.getText()).isEqualTo("");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,9 +31,7 @@ import androidx.test.filters.SmallTest;
|
||||
import com.android.keyguard.KeyguardDisplayManager.KeyguardPresentation;
|
||||
import com.android.keyguard.dagger.KeyguardStatusViewComponent;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.SystemUIFactory;
|
||||
import com.android.systemui.SysuiTestCase;
|
||||
import com.android.systemui.util.InjectionInflationController;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
@@ -65,7 +63,6 @@ public class KeyguardPresentationTest extends SysuiTestCase {
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mDependency.injectMockDependency(KeyguardUpdateMonitor.class);
|
||||
when(mMockKeyguardClockSwitch.getContext()).thenReturn(mContext);
|
||||
when(mMockKeyguardSliceView.getContext()).thenReturn(mContext);
|
||||
when(mMockKeyguardStatusView.getContext()).thenReturn(mContext);
|
||||
@@ -77,11 +74,7 @@ public class KeyguardPresentationTest extends SysuiTestCase {
|
||||
|
||||
allowTestableLooperAsMainThread();
|
||||
|
||||
InjectionInflationController inflationController = new InjectionInflationController(
|
||||
SystemUIFactory.getInstance()
|
||||
.getSysUIComponent()
|
||||
.createViewInstanceCreatorFactory());
|
||||
mLayoutInflater = inflationController.injectable(LayoutInflater.from(mContext));
|
||||
mLayoutInflater = LayoutInflater.from(mContext);
|
||||
mLayoutInflater.setPrivateFactory(new LayoutInflater.Factory2() {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -35,7 +35,6 @@ import androidx.test.filters.SmallTest;
|
||||
|
||||
import com.android.keyguard.KeyguardSecurityModel.SecurityMode;
|
||||
import com.android.systemui.SysuiTestCase;
|
||||
import com.android.systemui.util.InjectionInflationController;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
@@ -58,8 +57,6 @@ public class KeyguardSecurityViewFlipperControllerTest extends SysuiTestCase {
|
||||
@Mock
|
||||
private LayoutInflater mLayoutInflater;
|
||||
@Mock
|
||||
private InjectionInflationController mInjectionInflationController;
|
||||
@Mock
|
||||
private KeyguardInputViewController.Factory mKeyguardSecurityViewControllerFactory;
|
||||
@Mock
|
||||
private KeyguardInputViewController mKeyguardInputViewController;
|
||||
@@ -74,7 +71,6 @@ public class KeyguardSecurityViewFlipperControllerTest extends SysuiTestCase {
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
when(mInjectionInflationController.injectable(mLayoutInflater)).thenReturn(mLayoutInflater);
|
||||
when(mKeyguardSecurityViewControllerFactory.create(
|
||||
any(KeyguardInputView.class), any(SecurityMode.class),
|
||||
any(KeyguardSecurityCallback.class)))
|
||||
@@ -82,8 +78,7 @@ public class KeyguardSecurityViewFlipperControllerTest extends SysuiTestCase {
|
||||
when(mView.getWindowInsetsController()).thenReturn(mWindowInsetsController);
|
||||
|
||||
mKeyguardSecurityViewFlipperController = new KeyguardSecurityViewFlipperController(mView,
|
||||
mLayoutInflater, mInjectionInflationController,
|
||||
mKeyguardSecurityViewControllerFactory);
|
||||
mLayoutInflater, mKeyguardSecurityViewControllerFactory);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -24,9 +24,7 @@ import android.testing.TestableLooper.RunWithLooper;
|
||||
import android.view.LayoutInflater;
|
||||
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.SystemUIFactory;
|
||||
import com.android.systemui.SysuiTestCase;
|
||||
import com.android.systemui.util.InjectionInflationController;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -50,13 +48,7 @@ public class KeyguardStatusViewTest extends SysuiTestCase {
|
||||
@Before
|
||||
public void setUp() {
|
||||
allowTestableLooperAsMainThread();
|
||||
mDependency.injectMockDependency(KeyguardUpdateMonitor.class);
|
||||
InjectionInflationController inflationController = new InjectionInflationController(
|
||||
SystemUIFactory.getInstance()
|
||||
.getSysUIComponent()
|
||||
.createViewInstanceCreatorFactory());
|
||||
LayoutInflater layoutInflater = inflationController
|
||||
.injectable(LayoutInflater.from(getContext()));
|
||||
LayoutInflater layoutInflater = LayoutInflater.from(getContext());
|
||||
mKeyguardStatusView =
|
||||
(KeyguardStatusView) layoutInflater.inflate(R.layout.keyguard_status_view, null);
|
||||
org.mockito.MockitoAnnotations.initMocks(this);
|
||||
|
||||
Reference in New Issue
Block a user