1 /* 2 * Copyright (C) 2017 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.cts.deviceowner; 18 19 import static com.google.common.truth.Truth.assertWithMessage; 20 21 import android.content.pm.PackageManager; 22 23 /** 24 * Tests that DeviceOwner can add WifiConfigurations containing a HttpProxy 25 */ 26 public class WifiSetHttpProxyTest extends BaseDeviceOwnerTest { 27 28 private static final String TEST_PAC_URL = "http://www.example.com/proxy.pac"; 29 private static final String TEST_SSID = "SomeProxyApSsid"; 30 31 /** 32 * Test WifiManager.addNetwork() succeeds for a DeviceOwner adding a WifiConfiguraiton 33 * containing a HttpProxy. 34 * 2. Creates a new WifiConfiguration with ssid TEST_SSID 35 * 3. Adds a PAC proxy file URL to the WifiConfiguraiton 36 * 4. Adds the WifiConfiguration via WifiManager.addNetwork(), expects success 37 * 5. Verifies the added WifiConfiguration has the same proxy 38 */ testSetHttpProxy()39 public void testSetHttpProxy() { 40 PackageManager packageManager = mContext.getPackageManager(); 41 if (!packageManager.hasSystemFeature(PackageManager.FEATURE_WIFI)) { 42 // skip the test if WiFi is not supported 43 return; 44 } 45 String retrievedPacProxyUrl = mWifiConfigCreator.addHttpProxyNetworkVerifyAndRemove( 46 TEST_SSID, TEST_PAC_URL); 47 assertWithMessage("pacProxyUrl for SSID %s", TEST_SSID).that(retrievedPacProxyUrl) 48 .isEqualTo(TEST_PAC_URL); 49 } 50 } 51