Merge "Use a different context when constructing an EdgeBackGestureHandler." into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
16ff25f5a7
@@ -140,7 +140,6 @@ import java.util.function.Consumer;
|
|||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
import javax.inject.Provider;
|
|
||||||
|
|
||||||
import dagger.Lazy;
|
import dagger.Lazy;
|
||||||
|
|
||||||
@@ -199,12 +198,6 @@ public class Dependency {
|
|||||||
*/
|
*/
|
||||||
public static final String ALLOW_NOTIFICATION_LONG_PRESS_NAME = "allow_notif_longpress";
|
public static final String ALLOW_NOTIFICATION_LONG_PRESS_NAME = "allow_notif_longpress";
|
||||||
|
|
||||||
/**
|
|
||||||
* A provider of {@link EdgeBackGestureHandler}.
|
|
||||||
*/
|
|
||||||
public static final String EDGE_BACK_GESTURE_HANDLER_PROVIDER_NAME =
|
|
||||||
"edge_back_gesture_handler_provider";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Key for getting a background Looper for background work.
|
* Key for getting a background Looper for background work.
|
||||||
*/
|
*/
|
||||||
@@ -240,12 +233,6 @@ public class Dependency {
|
|||||||
*/
|
*/
|
||||||
public static final DependencyKey<String> LEAK_REPORT_EMAIL =
|
public static final DependencyKey<String> LEAK_REPORT_EMAIL =
|
||||||
new DependencyKey<>(LEAK_REPORT_EMAIL_NAME);
|
new DependencyKey<>(LEAK_REPORT_EMAIL_NAME);
|
||||||
/**
|
|
||||||
* Key for retrieving an Provider<EdgeBackGestureHandler>.
|
|
||||||
*/
|
|
||||||
public static final DependencyKey<Provider<EdgeBackGestureHandler>>
|
|
||||||
EDGE_BACK_GESTURE_HANDLER_PROVIDER =
|
|
||||||
new DependencyKey<>(EDGE_BACK_GESTURE_HANDLER_PROVIDER_NAME);
|
|
||||||
|
|
||||||
private final ArrayMap<Object, Object> mDependencies = new ArrayMap<>();
|
private final ArrayMap<Object, Object> mDependencies = new ArrayMap<>();
|
||||||
private final ArrayMap<Object, LazyDependencyCreator> mProviders = new ArrayMap<>();
|
private final ArrayMap<Object, LazyDependencyCreator> mProviders = new ArrayMap<>();
|
||||||
@@ -372,7 +359,7 @@ public class Dependency {
|
|||||||
@Inject Lazy<TelephonyListenerManager> mTelephonyListenerManager;
|
@Inject Lazy<TelephonyListenerManager> mTelephonyListenerManager;
|
||||||
@Inject Lazy<SystemStatusAnimationScheduler> mSystemStatusAnimationSchedulerLazy;
|
@Inject Lazy<SystemStatusAnimationScheduler> mSystemStatusAnimationSchedulerLazy;
|
||||||
@Inject Lazy<PrivacyDotViewController> mPrivacyDotViewControllerLazy;
|
@Inject Lazy<PrivacyDotViewController> mPrivacyDotViewControllerLazy;
|
||||||
@Inject Provider<EdgeBackGestureHandler> mEdgeBackGestureHandlerProvider;
|
@Inject Lazy<EdgeBackGestureHandler.Factory> mEdgeBackGestureHandlerFactoryLazy;
|
||||||
@Inject Lazy<UiEventLogger> mUiEventLogger;
|
@Inject Lazy<UiEventLogger> mUiEventLogger;
|
||||||
@Inject Lazy<FeatureFlags> mFeatureFlagsLazy;
|
@Inject Lazy<FeatureFlags> mFeatureFlagsLazy;
|
||||||
|
|
||||||
@@ -587,7 +574,8 @@ public class Dependency {
|
|||||||
mProviders.put(SystemStatusAnimationScheduler.class,
|
mProviders.put(SystemStatusAnimationScheduler.class,
|
||||||
mSystemStatusAnimationSchedulerLazy::get);
|
mSystemStatusAnimationSchedulerLazy::get);
|
||||||
mProviders.put(PrivacyDotViewController.class, mPrivacyDotViewControllerLazy::get);
|
mProviders.put(PrivacyDotViewController.class, mPrivacyDotViewControllerLazy::get);
|
||||||
mProviders.put(EDGE_BACK_GESTURE_HANDLER_PROVIDER, () -> mEdgeBackGestureHandlerProvider);
|
mProviders.put(EdgeBackGestureHandler.Factory.class,
|
||||||
|
mEdgeBackGestureHandlerFactoryLazy::get);
|
||||||
mProviders.put(UiEventLogger.class, mUiEventLogger::get);
|
mProviders.put(UiEventLogger.class, mUiEventLogger::get);
|
||||||
mProviders.put(FeatureFlags.class, mFeatureFlagsLazy::get);
|
mProviders.put(FeatureFlags.class, mFeatureFlagsLazy::get);
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ package com.android.systemui.navigationbar;
|
|||||||
|
|
||||||
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;
|
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;
|
||||||
|
|
||||||
import static com.android.systemui.Dependency.EDGE_BACK_GESTURE_HANDLER_PROVIDER;
|
|
||||||
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_HOME_DISABLED;
|
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_HOME_DISABLED;
|
||||||
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED;
|
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED;
|
||||||
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_OVERVIEW_DISABLED;
|
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_OVERVIEW_DISABLED;
|
||||||
@@ -340,7 +339,8 @@ public class NavigationBarView extends FrameLayout implements
|
|||||||
|
|
||||||
mNavColorSampleMargin = getResources()
|
mNavColorSampleMargin = getResources()
|
||||||
.getDimensionPixelSize(R.dimen.navigation_handle_sample_horizontal_margin);
|
.getDimensionPixelSize(R.dimen.navigation_handle_sample_horizontal_margin);
|
||||||
mEdgeBackGestureHandler = Dependency.get(EDGE_BACK_GESTURE_HANDLER_PROVIDER).get();
|
mEdgeBackGestureHandler = Dependency.get(EdgeBackGestureHandler.Factory.class)
|
||||||
|
.create(mContext);
|
||||||
mEdgeBackGestureHandler.setStateChangeCallback(this::updateStates);
|
mEdgeBackGestureHandler.setStateChangeCallback(this::updateStates);
|
||||||
mRegionSamplingHelper = new RegionSamplingHelper(this,
|
mRegionSamplingHelper = new RegionSamplingHelper(this,
|
||||||
new RegionSamplingHelper.SamplingCallback() {
|
new RegionSamplingHelper.SamplingCallback() {
|
||||||
|
|||||||
@@ -292,8 +292,8 @@ public class EdgeBackGestureHandler extends CurrentUserTracker
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@Inject
|
|
||||||
public EdgeBackGestureHandler(Context context, OverviewProxyService overviewProxyService,
|
EdgeBackGestureHandler(Context context, OverviewProxyService overviewProxyService,
|
||||||
SysUiState sysUiState, PluginManager pluginManager, @Main Executor executor,
|
SysUiState sysUiState, PluginManager pluginManager, @Main Executor executor,
|
||||||
BroadcastDispatcher broadcastDispatcher, ProtoTracer protoTracer,
|
BroadcastDispatcher broadcastDispatcher, ProtoTracer protoTracer,
|
||||||
NavigationModeController navigationModeController, ViewConfiguration viewConfiguration,
|
NavigationModeController navigationModeController, ViewConfiguration viewConfiguration,
|
||||||
@@ -942,6 +942,53 @@ public class EdgeBackGestureHandler extends CurrentUserTracker
|
|||||||
proto.edgeBackGestureHandler.allowGesture = mAllowGesture;
|
proto.edgeBackGestureHandler.allowGesture = mAllowGesture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Injectable instance to create a new EdgeBackGestureHandler.
|
||||||
|
*
|
||||||
|
* Necessary because we don't have good handling of per-display contexts at the moment. With
|
||||||
|
* this, you can pass in a specific context that knows what display it is in.
|
||||||
|
*/
|
||||||
|
public static class Factory {
|
||||||
|
private final OverviewProxyService mOverviewProxyService;
|
||||||
|
private final SysUiState mSysUiState;
|
||||||
|
private final PluginManager mPluginManager;
|
||||||
|
private final Executor mExecutor;
|
||||||
|
private final BroadcastDispatcher mBroadcastDispatcher;
|
||||||
|
private final ProtoTracer mProtoTracer;
|
||||||
|
private final NavigationModeController mNavigationModeController;
|
||||||
|
private final ViewConfiguration mViewConfiguration;
|
||||||
|
private final WindowManager mWindowManager;
|
||||||
|
private final IWindowManager mWindowManagerService;
|
||||||
|
private final FalsingManager mFalsingManager;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public Factory(OverviewProxyService overviewProxyService,
|
||||||
|
SysUiState sysUiState, PluginManager pluginManager, @Main Executor executor,
|
||||||
|
BroadcastDispatcher broadcastDispatcher, ProtoTracer protoTracer,
|
||||||
|
NavigationModeController navigationModeController,
|
||||||
|
ViewConfiguration viewConfiguration, WindowManager windowManager,
|
||||||
|
IWindowManager windowManagerService, FalsingManager falsingManager) {
|
||||||
|
mOverviewProxyService = overviewProxyService;
|
||||||
|
mSysUiState = sysUiState;
|
||||||
|
mPluginManager = pluginManager;
|
||||||
|
mExecutor = executor;
|
||||||
|
mBroadcastDispatcher = broadcastDispatcher;
|
||||||
|
mProtoTracer = protoTracer;
|
||||||
|
mNavigationModeController = navigationModeController;
|
||||||
|
mViewConfiguration = viewConfiguration;
|
||||||
|
mWindowManager = windowManager;
|
||||||
|
mWindowManagerService = windowManagerService;
|
||||||
|
mFalsingManager = falsingManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Construct a {@link EdgeBackGestureHandler}. */
|
||||||
|
public EdgeBackGestureHandler create(Context context) {
|
||||||
|
return new EdgeBackGestureHandler(context, mOverviewProxyService, mSysUiState,
|
||||||
|
mPluginManager, mExecutor, mBroadcastDispatcher, mProtoTracer,
|
||||||
|
mNavigationModeController, mViewConfiguration, mWindowManager,
|
||||||
|
mWindowManagerService, mFalsingManager);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static class LogArray extends ArrayDeque<String> {
|
private static class LogArray extends ArrayDeque<String> {
|
||||||
private final int mLength;
|
private final int mLength;
|
||||||
|
|||||||
@@ -16,12 +16,12 @@
|
|||||||
|
|
||||||
package com.android.systemui.navigationbar;
|
package com.android.systemui.navigationbar;
|
||||||
|
|
||||||
import static com.android.systemui.Dependency.EDGE_BACK_GESTURE_HANDLER_PROVIDER;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.graphics.PixelFormat;
|
import android.graphics.PixelFormat;
|
||||||
import android.hardware.display.DisplayManager;
|
import android.hardware.display.DisplayManager;
|
||||||
import android.hardware.display.VirtualDisplay;
|
import android.hardware.display.VirtualDisplay;
|
||||||
@@ -38,7 +38,6 @@ import androidx.test.filters.SmallTest;
|
|||||||
import com.android.systemui.SysuiTestCase;
|
import com.android.systemui.SysuiTestCase;
|
||||||
import com.android.systemui.SysuiTestableContext;
|
import com.android.systemui.SysuiTestableContext;
|
||||||
import com.android.systemui.assist.AssistManager;
|
import com.android.systemui.assist.AssistManager;
|
||||||
import com.android.systemui.navigationbar.NavigationBarView;
|
|
||||||
import com.android.systemui.navigationbar.gestural.EdgeBackGestureHandler;
|
import com.android.systemui.navigationbar.gestural.EdgeBackGestureHandler;
|
||||||
import com.android.systemui.recents.OverviewProxyService;
|
import com.android.systemui.recents.OverviewProxyService;
|
||||||
import com.android.systemui.statusbar.policy.KeyguardStateController;
|
import com.android.systemui.statusbar.policy.KeyguardStateController;
|
||||||
@@ -47,6 +46,8 @@ import org.junit.After;
|
|||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.MockitoAnnotations;
|
||||||
|
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
@@ -56,6 +57,10 @@ import java.util.function.Predicate;
|
|||||||
@SmallTest
|
@SmallTest
|
||||||
public class NavigationBarButtonTest extends SysuiTestCase {
|
public class NavigationBarButtonTest extends SysuiTestCase {
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
EdgeBackGestureHandler.Factory mEdgeBackGestureHandlerFactory;
|
||||||
|
@Mock
|
||||||
|
EdgeBackGestureHandler mEdgeBackGestureHandler;
|
||||||
private static final String TAG = "NavigationBarButtonTest";
|
private static final String TAG = "NavigationBarButtonTest";
|
||||||
private ImageReader mReader;
|
private ImageReader mReader;
|
||||||
private NavigationBarView mNavBar;
|
private NavigationBarView mNavBar;
|
||||||
@@ -63,16 +68,20 @@ public class NavigationBarButtonTest extends SysuiTestCase {
|
|||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
|
MockitoAnnotations.initMocks(this);
|
||||||
final Display display = createVirtualDisplay();
|
final Display display = createVirtualDisplay();
|
||||||
final SysuiTestableContext context =
|
final SysuiTestableContext context =
|
||||||
(SysuiTestableContext) mContext.createDisplayContext(display);
|
(SysuiTestableContext) mContext.createDisplayContext(display);
|
||||||
|
|
||||||
|
when(mEdgeBackGestureHandlerFactory.create(any(Context.class)))
|
||||||
|
.thenReturn(mEdgeBackGestureHandler);
|
||||||
|
|
||||||
mDependency.injectMockDependency(AssistManager.class);
|
mDependency.injectMockDependency(AssistManager.class);
|
||||||
mDependency.injectMockDependency(OverviewProxyService.class);
|
mDependency.injectMockDependency(OverviewProxyService.class);
|
||||||
mDependency.injectMockDependency(KeyguardStateController.class);
|
mDependency.injectMockDependency(KeyguardStateController.class);
|
||||||
mDependency.injectMockDependency(NavigationBarController.class);
|
mDependency.injectMockDependency(NavigationBarController.class);
|
||||||
mDependency.injectTestDependency(EDGE_BACK_GESTURE_HANDLER_PROVIDER,
|
mDependency.injectTestDependency(EdgeBackGestureHandler.Factory.class,
|
||||||
() -> mock(EdgeBackGestureHandler.class));
|
mEdgeBackGestureHandlerFactory);
|
||||||
mNavBar = new NavigationBarView(context, null);
|
mNavBar = new NavigationBarView(context, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import static android.view.Display.DEFAULT_DISPLAY;
|
|||||||
import static android.view.DisplayAdjustments.DEFAULT_DISPLAY_ADJUSTMENTS;
|
import static android.view.DisplayAdjustments.DEFAULT_DISPLAY_ADJUSTMENTS;
|
||||||
|
|
||||||
import static com.android.internal.config.sysui.SystemUiDeviceConfigFlags.HOME_BUTTON_LONG_PRESS_DURATION_MS;
|
import static com.android.internal.config.sysui.SystemUiDeviceConfigFlags.HOME_BUTTON_LONG_PRESS_DURATION_MS;
|
||||||
import static com.android.systemui.Dependency.EDGE_BACK_GESTURE_HANDLER_PROVIDER;
|
|
||||||
import static com.android.systemui.navigationbar.NavigationBar.NavBarActionEvent.NAVBAR_ASSIST_LONGPRESS;
|
import static com.android.systemui.navigationbar.NavigationBar.NavBarActionEvent.NAVBAR_ASSIST_LONGPRESS;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
@@ -119,6 +118,10 @@ public class NavigationBarTest extends SysuiTestCase {
|
|||||||
private BroadcastDispatcher mBroadcastDispatcher;
|
private BroadcastDispatcher mBroadcastDispatcher;
|
||||||
@Mock
|
@Mock
|
||||||
private UiEventLogger mUiEventLogger;
|
private UiEventLogger mUiEventLogger;
|
||||||
|
@Mock
|
||||||
|
EdgeBackGestureHandler.Factory mEdgeBackGestureHandlerFactory;
|
||||||
|
@Mock
|
||||||
|
EdgeBackGestureHandler mEdgeBackGestureHandler;
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public final LeakCheckedTest.SysuiLeakCheck mLeakCheck = new LeakCheckedTest.SysuiLeakCheck();
|
public final LeakCheckedTest.SysuiLeakCheck mLeakCheck = new LeakCheckedTest.SysuiLeakCheck();
|
||||||
@@ -129,6 +132,8 @@ public class NavigationBarTest extends SysuiTestCase {
|
|||||||
public void setup() throws Exception {
|
public void setup() throws Exception {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
|
|
||||||
|
when(mEdgeBackGestureHandlerFactory.create(any(Context.class)))
|
||||||
|
.thenReturn(mEdgeBackGestureHandler);
|
||||||
mCommandQueue = new CommandQueue(mContext);
|
mCommandQueue = new CommandQueue(mContext);
|
||||||
setupSysuiDependency();
|
setupSysuiDependency();
|
||||||
mDependency.injectMockDependency(AssistManager.class);
|
mDependency.injectMockDependency(AssistManager.class);
|
||||||
@@ -136,8 +141,8 @@ public class NavigationBarTest extends SysuiTestCase {
|
|||||||
mDependency.injectMockDependency(StatusBarStateController.class);
|
mDependency.injectMockDependency(StatusBarStateController.class);
|
||||||
mDependency.injectMockDependency(NavigationBarController.class);
|
mDependency.injectMockDependency(NavigationBarController.class);
|
||||||
mOverviewProxyService = mDependency.injectMockDependency(OverviewProxyService.class);
|
mOverviewProxyService = mDependency.injectMockDependency(OverviewProxyService.class);
|
||||||
mDependency.injectTestDependency(EDGE_BACK_GESTURE_HANDLER_PROVIDER,
|
mDependency.injectTestDependency(EdgeBackGestureHandler.Factory.class,
|
||||||
() -> mock(EdgeBackGestureHandler.class));
|
mEdgeBackGestureHandlerFactory);
|
||||||
TestableLooper.get(this).runWithLooper(() -> {
|
TestableLooper.get(this).runWithLooper(() -> {
|
||||||
mNavigationBar = createNavBar(mContext);
|
mNavigationBar = createNavBar(mContext);
|
||||||
mExternalDisplayNavigationBar = createNavBar(mSysuiTestableContextExternal);
|
mExternalDisplayNavigationBar = createNavBar(mSysuiTestableContextExternal);
|
||||||
|
|||||||
@@ -16,16 +16,16 @@
|
|||||||
|
|
||||||
package com.android.systemui.navigationbar;
|
package com.android.systemui.navigationbar;
|
||||||
|
|
||||||
import static com.android.systemui.Dependency.EDGE_BACK_GESTURE_HANDLER_PROVIDER;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.anyInt;
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
import static org.mockito.Mockito.doReturn;
|
import static org.mockito.Mockito.doReturn;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.spy;
|
import static org.mockito.Mockito.spy;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.testing.AndroidTestingRunner;
|
import android.testing.AndroidTestingRunner;
|
||||||
import android.testing.TestableLooper.RunWithLooper;
|
import android.testing.TestableLooper.RunWithLooper;
|
||||||
import android.view.IWindowManager;
|
import android.view.IWindowManager;
|
||||||
@@ -44,24 +44,34 @@ import com.android.systemui.statusbar.policy.KeyguardStateController;
|
|||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.MockitoAnnotations;
|
||||||
|
|
||||||
@RunWith(AndroidTestingRunner.class)
|
@RunWith(AndroidTestingRunner.class)
|
||||||
@RunWithLooper
|
@RunWithLooper
|
||||||
@SmallTest
|
@SmallTest
|
||||||
public class NavigationBarTransitionsTest extends SysuiTestCase {
|
public class NavigationBarTransitionsTest extends SysuiTestCase {
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
EdgeBackGestureHandler.Factory mEdgeBackGestureHandlerFactory;
|
||||||
|
@Mock
|
||||||
|
EdgeBackGestureHandler mEdgeBackGestureHandler;
|
||||||
private NavigationBarTransitions mTransitions;
|
private NavigationBarTransitions mTransitions;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
|
MockitoAnnotations.initMocks(this);
|
||||||
|
|
||||||
|
when(mEdgeBackGestureHandlerFactory.create(any(Context.class)))
|
||||||
|
.thenReturn(mEdgeBackGestureHandler);
|
||||||
mDependency.injectMockDependency(IWindowManager.class);
|
mDependency.injectMockDependency(IWindowManager.class);
|
||||||
mDependency.injectMockDependency(AssistManager.class);
|
mDependency.injectMockDependency(AssistManager.class);
|
||||||
mDependency.injectMockDependency(OverviewProxyService.class);
|
mDependency.injectMockDependency(OverviewProxyService.class);
|
||||||
mDependency.injectMockDependency(StatusBarStateController.class);
|
mDependency.injectMockDependency(StatusBarStateController.class);
|
||||||
mDependency.injectMockDependency(KeyguardStateController.class);
|
mDependency.injectMockDependency(KeyguardStateController.class);
|
||||||
mDependency.injectMockDependency(NavigationBarController.class);
|
mDependency.injectMockDependency(NavigationBarController.class);
|
||||||
mDependency.injectTestDependency(EDGE_BACK_GESTURE_HANDLER_PROVIDER,
|
mDependency.injectTestDependency(EdgeBackGestureHandler.Factory.class,
|
||||||
() -> mock(EdgeBackGestureHandler.class));
|
mEdgeBackGestureHandlerFactory);
|
||||||
doReturn(mContext)
|
doReturn(mContext)
|
||||||
.when(mDependency.injectMockDependency(NavigationModeController.class))
|
.when(mDependency.injectMockDependency(NavigationModeController.class))
|
||||||
.getCurrentUserContext();
|
.getCurrentUserContext();
|
||||||
|
|||||||
@@ -16,19 +16,20 @@
|
|||||||
|
|
||||||
package com.android.systemui.navigationbar.buttons;
|
package com.android.systemui.navigationbar.buttons;
|
||||||
|
|
||||||
import static com.android.systemui.Dependency.EDGE_BACK_GESTURE_HANDLER_PROVIDER;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertNotEquals;
|
import static org.junit.Assert.assertNotEquals;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.anyInt;
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
import static org.mockito.Mockito.doReturn;
|
import static org.mockito.Mockito.doReturn;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.spy;
|
import static org.mockito.Mockito.spy;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
@@ -37,15 +38,14 @@ import androidx.test.runner.AndroidJUnit4;
|
|||||||
|
|
||||||
import com.android.systemui.SysuiTestCase;
|
import com.android.systemui.SysuiTestCase;
|
||||||
import com.android.systemui.assist.AssistManager;
|
import com.android.systemui.assist.AssistManager;
|
||||||
import com.android.systemui.navigationbar.buttons.ContextualButton;
|
|
||||||
import com.android.systemui.navigationbar.buttons.ContextualButtonGroup;
|
|
||||||
import com.android.systemui.navigationbar.buttons.KeyButtonDrawable;
|
|
||||||
import com.android.systemui.navigationbar.gestural.EdgeBackGestureHandler;
|
import com.android.systemui.navigationbar.gestural.EdgeBackGestureHandler;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.MockitoAnnotations;
|
||||||
|
|
||||||
/** atest NavigationBarContextTest */
|
/** atest NavigationBarContextTest */
|
||||||
@SmallTest
|
@SmallTest
|
||||||
@@ -60,6 +60,11 @@ public class NavigationBarContextTest extends SysuiTestCase {
|
|||||||
private static final float DARK_INTENSITY_ERR = 0.0002f;
|
private static final float DARK_INTENSITY_ERR = 0.0002f;
|
||||||
private static final int ICON_RES_ID = 1;
|
private static final int ICON_RES_ID = 1;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
EdgeBackGestureHandler.Factory mEdgeBackGestureHandlerFactory;
|
||||||
|
@Mock
|
||||||
|
EdgeBackGestureHandler mEdgeBackGestureHandler;
|
||||||
|
|
||||||
private ContextualButtonGroup mGroup;
|
private ContextualButtonGroup mGroup;
|
||||||
private ContextualButton mBtn0;
|
private ContextualButton mBtn0;
|
||||||
private ContextualButton mBtn1;
|
private ContextualButton mBtn1;
|
||||||
@@ -67,9 +72,14 @@ public class NavigationBarContextTest extends SysuiTestCase {
|
|||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
|
MockitoAnnotations.initMocks(this);
|
||||||
|
|
||||||
|
when(mEdgeBackGestureHandlerFactory.create(any(Context.class)))
|
||||||
|
.thenReturn(mEdgeBackGestureHandler);
|
||||||
|
|
||||||
mDependency.injectMockDependency(AssistManager.class);
|
mDependency.injectMockDependency(AssistManager.class);
|
||||||
mDependency.injectTestDependency(EDGE_BACK_GESTURE_HANDLER_PROVIDER,
|
mDependency.injectTestDependency(EdgeBackGestureHandler.Factory.class,
|
||||||
() -> mock(EdgeBackGestureHandler.class));
|
mEdgeBackGestureHandlerFactory);
|
||||||
|
|
||||||
mGroup = new ContextualButtonGroup(GROUP_ID);
|
mGroup = new ContextualButtonGroup(GROUP_ID);
|
||||||
mBtn0 = new ContextualButton(BUTTON_0_ID, mContext, ICON_RES_ID);
|
mBtn0 = new ContextualButton(BUTTON_0_ID, mContext, ICON_RES_ID);
|
||||||
|
|||||||
@@ -16,18 +16,16 @@
|
|||||||
|
|
||||||
package com.android.systemui.navigationbar.buttons;
|
package com.android.systemui.navigationbar.buttons;
|
||||||
|
|
||||||
import static com.android.systemui.Dependency.EDGE_BACK_GESTURE_HANDLER_PROVIDER;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Mockito.doAnswer;
|
import static org.mockito.Mockito.doAnswer;
|
||||||
import static org.mockito.Mockito.mock;
|
|
||||||
import static org.mockito.Mockito.never;
|
import static org.mockito.Mockito.never;
|
||||||
import static org.mockito.Mockito.spy;
|
import static org.mockito.Mockito.spy;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.testing.AndroidTestingRunner;
|
import android.testing.AndroidTestingRunner;
|
||||||
@@ -38,12 +36,13 @@ import android.view.View;
|
|||||||
import androidx.test.filters.SmallTest;
|
import androidx.test.filters.SmallTest;
|
||||||
|
|
||||||
import com.android.systemui.SysuiTestCase;
|
import com.android.systemui.SysuiTestCase;
|
||||||
import com.android.systemui.navigationbar.buttons.NearestTouchFrame;
|
|
||||||
import com.android.systemui.navigationbar.gestural.EdgeBackGestureHandler;
|
import com.android.systemui.navigationbar.gestural.EdgeBackGestureHandler;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.MockitoAnnotations;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -52,12 +51,21 @@ import java.util.Map;
|
|||||||
@SmallTest
|
@SmallTest
|
||||||
public class NearestTouchFrameTest extends SysuiTestCase {
|
public class NearestTouchFrameTest extends SysuiTestCase {
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
EdgeBackGestureHandler.Factory mEdgeBackGestureHandlerFactory;
|
||||||
|
@Mock
|
||||||
|
EdgeBackGestureHandler mEdgeBackGestureHandler;
|
||||||
private NearestTouchFrame mNearestTouchFrame;
|
private NearestTouchFrame mNearestTouchFrame;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
mDependency.injectTestDependency(EDGE_BACK_GESTURE_HANDLER_PROVIDER,
|
MockitoAnnotations.initMocks(this);
|
||||||
() -> mock(EdgeBackGestureHandler.class));
|
|
||||||
|
when(mEdgeBackGestureHandlerFactory.create(any(Context.class)))
|
||||||
|
.thenReturn(mEdgeBackGestureHandler);
|
||||||
|
|
||||||
|
mDependency.injectTestDependency(EdgeBackGestureHandler.Factory.class,
|
||||||
|
mEdgeBackGestureHandlerFactory);
|
||||||
Configuration c = new Configuration(mContext.getResources().getConfiguration());
|
Configuration c = new Configuration(mContext.getResources().getConfiguration());
|
||||||
c.smallestScreenWidthDp = 500;
|
c.smallestScreenWidthDp = 500;
|
||||||
mNearestTouchFrame = new NearestTouchFrame(mContext, null, c);
|
mNearestTouchFrame = new NearestTouchFrame(mContext, null, c);
|
||||||
|
|||||||
Reference in New Issue
Block a user