• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2014 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 
17 package com.android.sdk.tests;
18 
19 import com.android.ddmlib.EmulatorConsole;
20 import com.android.tradefed.build.IBuildInfo;
21 import com.android.tradefed.device.DeviceNotAvailableException;
22 import com.android.tradefed.device.ITestDevice;
23 import com.android.tradefed.targetprep.BaseTargetPreparer;
24 import com.android.tradefed.targetprep.BuildError;
25 import com.android.tradefed.targetprep.TargetSetupError;
26 
27 import org.junit.Assert;
28 
29 /** Sends and SMS message to the emulator */
30 public class EmulatorSmsPreparer extends BaseTargetPreparer {
31 
32     /** {@inheritDoc} */
33     @Override
setUp(ITestDevice device, IBuildInfo buildInfo)34     public void setUp(ITestDevice device, IBuildInfo buildInfo)
35             throws TargetSetupError, BuildError, DeviceNotAvailableException {
36         Assert.assertTrue("device is not a emulator", device.getIDevice().isEmulator());
37         EmulatorConsole console = EmulatorConsole.getConsole(device.getIDevice());
38         // these values mus match exactly with platform/development/tools/emulator/...
39         // test-apps/SmsTest/src/com/android/emulator/test/SmsTest.java
40         console.sendSms("5551212", "test sms");
41     }
42 }
43