Merge "Using WifiCommand to toggle the Wi-Fi state"
This commit is contained in:
@@ -33,14 +33,15 @@ import android.os.ParcelFileDescriptor.AutoCloseInputStream;
|
|||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
import android.support.test.uiautomator.UiDevice;
|
||||||
import android.test.InstrumentationTestCase;
|
import android.test.InstrumentationTestCase;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import libcore.io.Streams;
|
|
||||||
|
|
||||||
import com.google.mockwebserver.MockResponse;
|
import com.google.mockwebserver.MockResponse;
|
||||||
import com.google.mockwebserver.MockWebServer;
|
import com.google.mockwebserver.MockWebServer;
|
||||||
|
|
||||||
|
import libcore.io.Streams;
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -63,6 +64,7 @@ public class DownloadManagerBaseTest extends InstrumentationTestCase {
|
|||||||
private static final String TAG = "DownloadManagerBaseTest";
|
private static final String TAG = "DownloadManagerBaseTest";
|
||||||
protected DownloadManager mDownloadManager = null;
|
protected DownloadManager mDownloadManager = null;
|
||||||
private MockWebServer mServer = null;
|
private MockWebServer mServer = null;
|
||||||
|
private UiDevice mUiDevice = null;
|
||||||
protected String mFileType = "text/plain";
|
protected String mFileType = "text/plain";
|
||||||
protected Context mContext = null;
|
protected Context mContext = null;
|
||||||
protected MultipleDownloadsCompletedReceiver mReceiver = null;
|
protected MultipleDownloadsCompletedReceiver mReceiver = null;
|
||||||
@@ -234,6 +236,7 @@ public class DownloadManagerBaseTest extends InstrumentationTestCase {
|
|||||||
@Override
|
@Override
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
mContext = getInstrumentation().getContext();
|
mContext = getInstrumentation().getContext();
|
||||||
|
mUiDevice = UiDevice.getInstance(getInstrumentation());
|
||||||
mDownloadManager = (DownloadManager)mContext.getSystemService(Context.DOWNLOAD_SERVICE);
|
mDownloadManager = (DownloadManager)mContext.getSystemService(Context.DOWNLOAD_SERVICE);
|
||||||
mServer = new MockWebServer();
|
mServer = new MockWebServer();
|
||||||
mServer.play();
|
mServer.play();
|
||||||
@@ -512,7 +515,7 @@ public class DownloadManagerBaseTest extends InstrumentationTestCase {
|
|||||||
Log.i(LOG_TAG, "Setting WiFi State to: " + enable);
|
Log.i(LOG_TAG, "Setting WiFi State to: " + enable);
|
||||||
WifiManager manager = (WifiManager)mContext.getSystemService(Context.WIFI_SERVICE);
|
WifiManager manager = (WifiManager)mContext.getSystemService(Context.WIFI_SERVICE);
|
||||||
|
|
||||||
manager.setWifiEnabled(enable);
|
mUiDevice.executeShellCommand("svc wifi " + (enable ? "enable" : "disable"));
|
||||||
|
|
||||||
String timeoutMessage = "Timed out waiting for Wifi to be "
|
String timeoutMessage = "Timed out waiting for Wifi to be "
|
||||||
+ (enable ? "enabled!" : "disabled!");
|
+ (enable ? "enabled!" : "disabled!");
|
||||||
|
|||||||
Reference in New Issue
Block a user