1 /*
2  * Copyright (C) 2024 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package com.android.sdksandbox.next;
17 
18 import static com.google.common.truth.Truth.assertThat;
19 
20 import static org.junit.Assume.assumeTrue;
21 
22 import android.app.sdksandbox.testutils.DeviceSupportUtils;
23 import android.os.SELinux;
24 import android.platform.test.annotations.RequiresFlagsEnabled;
25 import android.platform.test.flag.junit.CheckFlagsRule;
26 import android.platform.test.flag.junit.DeviceFlagsValueProvider;
27 
28 import androidx.test.platform.app.InstrumentationRegistry;
29 
30 import com.android.sdksandbox.flags.Flags;
31 
32 import org.junit.Before;
33 import org.junit.Rule;
34 import org.junit.Test;
35 import org.junit.runner.RunWith;
36 import org.junit.runners.JUnit4;
37 
38 /** Tests to check some basic properties of the Sdk Sandbox next process. */
39 @RunWith(JUnit4.class)
40 public class SdkSandboxNextTest {
41 
42     @Rule
43     public final CheckFlagsRule mCheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule();
44 
45     @Before
setUp()46     public void setUp() {
47         assumeTrue(
48                 DeviceSupportUtils.isSdkSandboxSupported(
49                         InstrumentationRegistry.getInstrumentation().getContext()));
50     }
51 
52     @Test
53     @RequiresFlagsEnabled(Flags.FLAG_SELINUX_INPUT_SELECTOR)
testSdkSandboxNextDomain()54     public void testSdkSandboxNextDomain() {
55         assertThat(SELinux.getContext()).contains("u:r:sdk_sandbox_next");
56     }
57 }
58