Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ae2a483d authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "SystemServer: parametrized test for current flags" into main

parents b5927ac9 5ee00f22
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -654,9 +654,14 @@ class BluetoothManagerService {
                mHandler);

        if (Flags.getNameAndAddressAsCallback()) {
            mName = Settings.Secure.getString(mContentResolver, Settings.Secure.BLUETOOTH_NAME);
            mName =
                    BluetoothServerProxy.getInstance()
                            .settingsSecureGetString(
                                    mContentResolver, Settings.Secure.BLUETOOTH_NAME);
            mAddress =
                    Settings.Secure.getString(mContentResolver, Settings.Secure.BLUETOOTH_ADDRESS);
                    BluetoothServerProxy.getInstance()
                            .settingsSecureGetString(
                                    mContentResolver, Settings.Secure.BLUETOOTH_ADDRESS);

            Log.d(TAG, "Local adapter: Name=" + mName + ", Address=" + logAddress(mAddress));
        } else {
+1 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ android_test {
        "libprotobuf-java-nano",
        "mockito-target-extended-minus-junit4",
        "platform-compat-test-rules",
        "platform-parametric-runner-lib",
        "platform-test-annotations",

        // Linking source to test the working copy, not the on-device copy.
+25 −3
Original line number Diff line number Diff line
@@ -59,13 +59,17 @@ import android.os.Message;
import android.os.UserHandle;
import android.os.UserManager;
import android.os.test.TestLooper;
import android.platform.test.flag.junit.FlagsParameterization;
import android.platform.test.flag.junit.SetFlagsRule;
import android.provider.Settings;

import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;

import com.android.bluetooth.flags.Flags;

import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
@@ -73,11 +77,29 @@ import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.Spy;

import platform.test.runner.parameterized.ParameterizedAndroidJunit4;
import platform.test.runner.parameterized.Parameters;

import java.util.List;
import java.util.stream.IntStream;

@RunWith(AndroidJUnit4.class)
@RunWith(ParameterizedAndroidJunit4.class)
public class BluetoothManagerServiceTest {
    private static final String TAG = BluetoothManagerServiceTest.class.getSimpleName();

    @Rule public final SetFlagsRule mSetFlagsRule;

    @Parameters(name = "{0}")
    public static List<FlagsParameterization> getParams() {
        return FlagsParameterization.allCombinationsOf(
                Flags.FLAG_GET_NAME_AND_ADDRESS_AS_CALLBACK,
                Flags.FLAG_ENFORCE_RESOLVE_SYSTEM_SERVICE_BEHAVIOR,
                Flags.FLAG_REMOVE_ONE_TIME_GET_NAME_AND_ADDRESS);
    }

    public BluetoothManagerServiceTest(FlagsParameterization flags) {
        mSetFlagsRule = new SetFlagsRule(flags);
    }

    private static final int STATE_BLE_TURNING_ON = 14; // can't find the symbol because hidden api

    BluetoothManagerService mManagerService;