[Testing] To migration DefaultSubscriptionControllerTest
1. Use AndroidJunit4 instead of RobolectricTestRunner 2. Use ApplicationProvider instead of RuntimeEnvironment to get context 3. Change Copy Right 4. Create new class and add a function which loads the Settings Resource. 5. remove getOnPreferenceChangeListener. Becasue the error: java.lang.NoSuchMethodError: No virtual method getOnPreferenceChangeListener() Bug: 173004787 Test: atest -c DefaultSubscriptionControllerTest Change-Id: Iac9834f2a47bd8b50234646197a31058ffacaa4b
This commit is contained in:
28
tests/unit/src/com/android/settings/testutils/Utils.java
Normal file
28
tests/unit/src/com/android/settings/testutils/Utils.java
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.android.settings.testutils;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
public final class Utils {
|
||||
public static int getResourceId(Context context, String type, String name) {
|
||||
return context.getResources().getIdentifier(name, type, context.getPackageName());
|
||||
}
|
||||
|
||||
public static String getResourceString(Context context, String name) {
|
||||
return context.getResources().getString(getResourceId(context, "string", name));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user