1/* 2 * Copyright (C) 2010 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 17package com.android.telephonymockriltests.functional; 18 19import com.android.internal.telephony.mockril.MockRilController; 20import android.test.InstrumentationTestCase; 21import android.util.Log; 22 23import com.android.telephonymockriltests.TelephonyMockTestRunner; 24 25/** 26 * A simple test that using Mock RIL Controller 27 */ 28public class SimpleTestUsingMockRil extends InstrumentationTestCase { 29 private static final String TAG = "SimpleTestUsingMockRil"; 30 private MockRilController mMockRilCtrl = null; 31 private TelephonyMockTestRunner mRunner; 32 33 @Override 34 public void setUp() throws Exception { 35 super.setUp(); 36 mRunner = (TelephonyMockTestRunner)getInstrumentation(); 37 mMockRilCtrl = mRunner.mController; 38 assertNotNull(mMockRilCtrl); 39 } 40 41 /** 42 * Get the current radio state of RIL 43 */ 44 public void testGetRadioState() { 45 int state = mMockRilCtrl.getRadioState(); 46 Log.v(TAG, "testGetRadioState: " + state); 47 assertTrue(state >= 0 && state <= 9); 48 } 49 50 /** 51 * Set the current radio state of RIL 52 * and verify the radio state is set correctly 53 */ 54 public void testSetRadioState() { 55 for (int state = 0; state <= 9; state++) { 56 Log.v(TAG, "set radio state to be " + state); 57 assertTrue("set radio state: " + state + " failed.", 58 mMockRilCtrl.setRadioState(state)); 59 } 60 assertFalse("use an invalid radio state", mMockRilCtrl.setRadioState(-1)); 61 assertFalse("the radio state doesn't exist", mMockRilCtrl.setRadioState(10)); 62 } 63} 64