1 /* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file 5 * except in compliance with the License. You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software distributed under the 10 * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 11 * KIND, either express or implied. See the License for the specific language governing 12 * permissions and limitations under the License. 13 */ 14 15 package com.android.systemui; 16 17 import static org.junit.Assert.assertEquals; 18 import static org.mockito.Mockito.mock; 19 20 import android.os.Looper; 21 22 import androidx.test.filters.SmallTest; 23 24 import com.android.systemui.statusbar.policy.FlashlightController; 25 26 import org.junit.Assert; 27 import org.junit.Test; 28 29 import java.util.concurrent.ExecutionException; 30 31 @SmallTest 32 public class DependencyTest extends SysuiTestCase { 33 34 @Test testClassDependency()35 public void testClassDependency() { 36 FlashlightController f = mock(FlashlightController.class); 37 mDependency.injectTestDependency(FlashlightController.class, f); 38 Assert.assertEquals(f, Dependency.get(FlashlightController.class)); 39 } 40 41 @Test testStringDependency()42 public void testStringDependency() { 43 Looper l = Looper.getMainLooper(); 44 mDependency.injectTestDependency(Dependency.BG_LOOPER, l); 45 assertEquals(l, Dependency.get(Dependency.BG_LOOPER)); 46 } 47 48 @Test testInitDependency()49 public void testInitDependency() throws ExecutionException, InterruptedException { 50 Dependency.clearDependencies(); 51 SystemUIInitializer initializer = 52 SystemUIInitializerFactory.createFromConfigNoAssert(mContext); 53 initializer.init(true); 54 Dependency dependency = initializer.getSysUIComponent().createDependency(); 55 dependency.start(); 56 } 57 } 58