• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2021 The Bazel Authors. All rights reserved.
3  *
4  * <p>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  * <p>http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * <p>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 KIND, either
11  * express or implied. See the License for the specific language governing permissions and
12  * limitations under the License.
13  */
14 package com.starlark_resources;
15 
16 import static org.junit.Assert.assertEquals;
17 
18 import android.content.Context;
19 import android.content.res.Resources;
20 import androidx.test.core.app.ApplicationProvider;
21 import androidx.test.ext.junit.runners.AndroidJUnit4;
22 import org.junit.Before;
23 import org.junit.Test;
24 import org.junit.runner.RunWith;
25 
26 @RunWith(AndroidJUnit4.class)
27 public class SampleTest {
28   private Context targetContext;
29   private Resources resources;
30 
31   @Before
setup()32   public void setup() throws Exception {
33     targetContext = ApplicationProvider.getApplicationContext();
34     resources = targetContext.getResources();
35   }
36 
37   @Test
test()38   public void test() throws Exception {
39     assertEquals("Check package name", "com.starlark_resources", targetContext.getPackageName());
40     assertEquals(
41         "Check resource `a_string`", "Hello World!", resources.getString(R.string.a_string));
42   }
43 }
44