コード例 #1
0
ファイル: ScanResultTest.java プロジェクト: rcoscali/cts
  public void testScanResultTimeStamp() throws Exception {
    if (!WifiFeature.isWifiSupported(getContext())) {
      // skip the test if WiFi is not supported
      return;
    }

    long timestamp = 0;
    String BSSID = null;

    /* Multiple scans to ensure bssid is updated */
    scanAndWait();
    scanAndWait();
    scanAndWait();

    List<ScanResult> scanResults = mWifiManager.getScanResults();
    for (ScanResult result : scanResults) {
      BSSID = result.BSSID;
      timestamp = result.timestamp;
      assertTrue(timestamp != 0);
      break;
    }

    scanAndWait();
    scanAndWait();
    scanAndWait();

    scanResults = mWifiManager.getScanResults();
    for (ScanResult result : scanResults) {
      if (result.BSSID.equals(BSSID)) {
        long timeDiff = (result.timestamp - timestamp) / 1000;
        assertTrue(timeDiff > 0);
        assertTrue(timeDiff < 6 * SCAN_WAIT_MSEC);
      }
    }
  }
コード例 #2
0
ファイル: ScanResultTest.java プロジェクト: rcoscali/cts
  @Override
  protected void setUp() throws Exception {
    super.setUp();
    if (!WifiFeature.isWifiSupported(getContext())) {
      // skip the test if WiFi is not supported
      return;
    }
    mMySync = new MySync();
    mIntentFilter = new IntentFilter();
    mIntentFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
    mIntentFilter.addAction(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION);
    mIntentFilter.addAction(WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION);
    mIntentFilter.addAction(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION);
    mIntentFilter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);
    mIntentFilter.addAction(WifiManager.RSSI_CHANGED_ACTION);
    mIntentFilter.addAction(WifiManager.NETWORK_IDS_CHANGED_ACTION);
    mIntentFilter.addAction(WifiManager.ACTION_PICK_WIFI_NETWORK);

    mContext.registerReceiver(mReceiver, mIntentFilter);
    mWifiManager = (WifiManager) getContext().getSystemService(Context.WIFI_SERVICE);
    assertNotNull(mWifiManager);
    mWifiLock = mWifiManager.createWifiLock(TAG);
    mWifiLock.acquire();
    if (!mWifiManager.isWifiEnabled()) setWifiEnabled(true);
    Thread.sleep(ENABLE_WAIT_MSEC);
    assertTrue(mWifiManager.isWifiEnabled());
    mMySync.expectedState = STATE_NULL;
  }
コード例 #3
0
ファイル: ScanResultTest.java プロジェクト: rcoscali/cts
 public void testScanResultProperties() {
   if (!WifiFeature.isWifiSupported(getContext())) {
     // skip the test if WiFi is not supported
     return;
   }
   List<ScanResult> scanResults = mWifiManager.getScanResults();
   // this test case should in Wifi environment
   for (int i = 0; i < scanResults.size(); i++) {
     ScanResult mScanResult = scanResults.get(i);
     assertNotNull(mScanResult.toString());
   }
 }
コード例 #4
0
ファイル: ScanResultTest.java プロジェクト: rcoscali/cts
 @Override
 protected void tearDown() throws Exception {
   if (!WifiFeature.isWifiSupported(getContext())) {
     // skip the test if WiFi is not supported
     super.tearDown();
     return;
   }
   mWifiLock.release();
   mContext.unregisterReceiver(mReceiver);
   if (!mWifiManager.isWifiEnabled()) setWifiEnabled(true);
   Thread.sleep(ENABLE_WAIT_MSEC);
   super.tearDown();
 }