Skip to content

Commit

Permalink
Merge pull request #7 from isuPatches/develop
Browse files Browse the repository at this point in the history
v1.0.2
  • Loading branch information
isuPatches committed Apr 30, 2016
2 parents 3ba209b + 12bb210 commit cdc6695
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ android {
defaultConfig {
minSdkVersion 16
targetSdkVersion 23
versionCode 2
versionName "1.0.1"
versionCode 3
versionName "1.0.2"
}

buildTypes {
Expand Down
32 changes: 31 additions & 1 deletion app/src/androidTest/java/com/metova/wisefy/WiseFyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import com.metova.wisefy.util.GetManagerUtil;
import com.metova.wisefy.util.TestActivity;
import com.robotium.solo.Condition;
import org.mockito.Mockito;
import java.util.ArrayList;
import java.util.List;
import static org.mockito.Mockito.*;
Expand Down Expand Up @@ -257,6 +256,37 @@ public void testIsSecureNullCapabilities() {
assertEquals(false, WiseFy.getSmarts().isSecure(scanResult));
}

public void testIsWiFiEnabledFalse() {
final WifiManager wifiManager = getLiveWiFiManager(getActivity());
wifiManager.setWifiEnabled(false);
assertTrue(getSolo().waitForCondition(new Condition() {
@Override
public boolean isSatisfied() {
return !wifiManager.isWifiEnabled();
}
}, 3000));
assertEquals(false, WiseFy.getSmarts().isWifiEnabled(getActivity()));
wifiManager.setWifiEnabled(true);
assertTrue(getSolo().waitForCondition(new Condition() {
@Override
public boolean isSatisfied() {
return wifiManager.isWifiEnabled();
}
}, 3000));
}

public void testIsWifiEnabledTrue() {
final WifiManager wifiManager = getLiveWiFiManager(getActivity());
wifiManager.setWifiEnabled(true);
assertTrue(getSolo().waitForCondition(new Condition() {
@Override
public boolean isSatisfied() {
return wifiManager.isWifiEnabled();
}
}, 3000));
assertEquals(true, WiseFy.getSmarts().isWifiEnabled(getActivity()));
}

public void testReconnectToNetworkSuccess() {
WiseFy.getSmarts().mGetManagerUtil = mMockGetManagerUtil;
List<WifiConfiguration> wifiList = new ArrayList<>();
Expand Down
18 changes: 18 additions & 0 deletions app/src/main/java/com/metova/wisefy/WiseFy.java
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,24 @@ public boolean isSecure(ScanResult scanResult) {
return isSecure;
}


/**
* To check if Wifi is enabled on the device or not
*
* @param activity - The activity to use as context to retrieve a wifi manager via getSystemService
* @return boolean - if Wifi is enabled on device
*/
public boolean isWifiEnabled(Activity activity) {
boolean isWifiEnabled = false;
if(activity != null) {
WifiManager wifiManager = GetManagerUtil.getInstance().getWiFiManager(activity);
isWifiEnabled = wifiManager.isWifiEnabled();
} else {
LogUtil.w(TAG, "No activity to get wifi config");
}
return isWifiEnabled;
}

/**
* Used to reconnect to a network
*
Expand Down

0 comments on commit cdc6695

Please sign in to comment.