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 @SmallTest
30 public class DependencyTest extends SysuiTestCase {
31 
32     @Test
testClassDependency()33     public void testClassDependency() {
34         FlashlightController f = mock(FlashlightController.class);
35         mDependency.injectTestDependency(FlashlightController.class, f);
36         Assert.assertEquals(f, Dependency.get(FlashlightController.class));
37     }
38 
39     @Test
testStringDependency()40     public void testStringDependency() {
41         Looper l = Looper.getMainLooper();
42         mDependency.injectTestDependency(Dependency.BG_LOOPER, l);
43         assertEquals(l, Dependency.get(Dependency.BG_LOOPER));
44     }
45 
46     @Test
testInitDependency()47     public void testInitDependency() {
48         Dependency.clearDependencies();
49         Dependency dependency = new Dependency();
50         SystemUIFactory
51                 .getInstance().getRootComponent().createDependency().createSystemUI(dependency);
52         dependency.start();
53     }
54 }
55