summaryrefslogtreecommitdiffstats
path: root/tests/unit/src/com/android/cellbroadcastreceiver/CellBroadcastTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/src/com/android/cellbroadcastreceiver/CellBroadcastTest.java')
-rw-r--r--tests/unit/src/com/android/cellbroadcastreceiver/CellBroadcastTest.java74
1 files changed, 74 insertions, 0 deletions
diff --git a/tests/unit/src/com/android/cellbroadcastreceiver/CellBroadcastTest.java b/tests/unit/src/com/android/cellbroadcastreceiver/CellBroadcastTest.java
new file mode 100644
index 00000000..2a1b8b34
--- /dev/null
+++ b/tests/unit/src/com/android/cellbroadcastreceiver/CellBroadcastTest.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2016 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.cellbroadcastreceiver;
+
+import android.content.Context;
+import android.os.PersistableBundle;
+import android.util.Log;
+import android.telephony.CarrierConfigManager;
+import android.util.SparseArray;
+
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.anyInt;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+public abstract class CellBroadcastTest {
+
+ protected static String TAG;
+
+ private SparseArray<PersistableBundle> mBundles = new SparseArray<>();
+
+ @Mock
+ Context mContext;
+ @Mock
+ CarrierConfigManager mCarrierConfigManager;
+
+ protected void setUp(String tag) throws Exception {
+ TAG = tag;
+ MockitoAnnotations.initMocks(this);
+ initContext();
+ }
+
+ private void initContext() {
+ doReturn(mCarrierConfigManager).when(mContext).
+ getSystemService(eq(Context.CARRIER_CONFIG_SERVICE));
+ }
+
+ protected void carrierConfigSetStringArray(int subId, String key, String[] values) {
+ //doReturn(values).when(mCarrierConfigManager.getConfig(subId)).getStringArray(eq(key));
+ if (mBundles.get(subId) == null) {
+ mBundles.put(subId, new PersistableBundle());
+ }
+ mBundles.get(subId).putStringArray(key, values);
+ doReturn(mBundles.get(subId)).when(mCarrierConfigManager).getConfigForSubId(eq(subId));
+ }
+
+ protected void tearDown() throws Exception {
+ }
+
+ protected static void logd(String s) {
+ Log.d(TAG, s);
+ }
+}