• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2011 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 /** Injects specific gps location into emulator. */
30 public class EmulatorGpsPreparer extends BaseTargetPreparer {
31 
32     // default gps location for the gps test
33     // TODO: make these options rather than hardcoding
34     private static final double LONGITUDE = -122.08345770835876;
35     private static final double LATITUDE = 37.41991859119417;
36 
37     /** {@inheritDoc} */
38     @Override
setUp(ITestDevice device, IBuildInfo buildInfo)39     public void setUp(ITestDevice device, IBuildInfo buildInfo)
40             throws TargetSetupError, BuildError, DeviceNotAvailableException {
41         Assert.assertTrue("device is not a emulator", device.getIDevice().isEmulator());
42         EmulatorConsole console = EmulatorConsole.getConsole(device.getIDevice());
43         console.sendLocation(LONGITUDE, LATITUDE, 0);
44     }
45 }
46