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 
19 import android.os.Looper;
20 
21 import androidx.test.filters.SmallTest;
22 
23 import org.junit.Assert;
24 import org.junit.Test;
25 
26 import java.util.concurrent.ExecutionException;
27 
28 @SmallTest
29 public class DependencyTest extends SysuiTestCase {
30 
31     @Test
testClassDependency()32     public void testClassDependency() {
33         FakeClass f = new FakeClass();
34         mDependency.injectTestDependency(FakeClass.class, f);
35         Assert.assertEquals(f, Dependency.get(FakeClass.class));
36     }
37 
38     @Test
testStringDependency()39     public void testStringDependency() {
40         Looper l = Looper.getMainLooper();
41         mDependency.injectTestDependency(Dependency.BG_LOOPER, l);
42         assertEquals(l, Dependency.get(Dependency.BG_LOOPER));
43     }
44 
45     @Test
testInitDependency()46     public void testInitDependency() throws ExecutionException, InterruptedException {
47         Dependency.clearDependencies();
48         SystemUIInitializer initializer = new SystemUIInitializerImpl(mContext);
49         initializer.init(true);
50         Dependency dependency = initializer.getSysUIComponent().createDependency();
51         dependency.start();
52     }
53 
54     private static class FakeClass {
55 
56     }
57 }
58