From 7b36438c5ce3b2c76a738caff8f540248e62cc20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Wed, 22 Apr 2015 18:12:49 +0200 Subject: Method to see if a view is actually shown. Thanks to http://stackoverflow.com/questions/3791607/how-can-i-check-if-a-view-is-visible-or-not-in-android/12428208#12428208 --- .../leap/bitmaskclient/test/testDashboardIntegration.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java') diff --git a/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java b/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java index d2fb9901..ee217e15 100644 --- a/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java +++ b/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java @@ -1,7 +1,9 @@ package se.leap.bitmaskclient.test; import android.content.*; +import android.graphics.Rect; import android.test.*; +import android.view.View; import android.widget.*; import com.robotium.solo.*; @@ -215,6 +217,17 @@ public class testDashboardIntegration extends ActivityInstrumentationTestCase2 Date: Thu, 23 Apr 2015 16:41:03 +0200 Subject: Test to check that the vpn button is shown Fixed more tests, broken due to previous pullreqs... --- .../test/testDashboardIntegration.java | 69 ++++++++++------------ 1 file changed, 31 insertions(+), 38 deletions(-) (limited to 'app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java') diff --git a/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java b/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java index ee217e15..42cabea9 100644 --- a/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java +++ b/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java @@ -1,9 +1,9 @@ package se.leap.bitmaskclient.test; import android.content.*; -import android.graphics.Rect; +import android.graphics.*; import android.test.*; -import android.view.View; +import android.view.*; import android.widget.*; import com.robotium.solo.*; @@ -11,6 +11,7 @@ import com.robotium.solo.*; import java.io.*; import de.blinkt.openvpn.activities.*; +import mbanje.kurt.fabbutton.FabButton; import se.leap.bitmaskclient.*; public class testDashboardIntegration extends ActivityInstrumentationTestCase2 { @@ -43,19 +44,19 @@ public class testDashboardIntegration extends ActivityInstrumentationTestCase2 Date: Thu, 23 Apr 2015 18:36:36 +0200 Subject: Tests pay attention to the vpn icon to know status They were relying on status messages, but I've removed that TextView. --- .../test/testDashboardIntegration.java | 64 +++++++++++++++++----- 1 file changed, 49 insertions(+), 15 deletions(-) (limited to 'app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java') diff --git a/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java b/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java index 42cabea9..68416b4a 100644 --- a/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java +++ b/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java @@ -4,14 +4,15 @@ import android.content.*; import android.graphics.*; import android.test.*; import android.view.*; -import android.widget.*; import com.robotium.solo.*; import java.io.*; import de.blinkt.openvpn.activities.*; +import mbanje.kurt.fabbutton.CircleImageView; import mbanje.kurt.fabbutton.FabButton; +import mbanje.kurt.fabbutton.ProgressRingView; import se.leap.bitmaskclient.*; public class testDashboardIntegration extends ActivityInstrumentationTestCase2 { @@ -66,32 +67,61 @@ public class testDashboardIntegration extends ActivityInstrumentationTestCase2 Date: Mon, 27 Apr 2015 17:10:20 +0200 Subject: testEveryProvider also works --- .../test/testDashboardIntegration.java | 45 +++++++++++----------- 1 file changed, 22 insertions(+), 23 deletions(-) (limited to 'app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java') diff --git a/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java b/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java index 68416b4a..06fe0a42 100644 --- a/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java +++ b/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java @@ -4,6 +4,7 @@ import android.content.*; import android.graphics.*; import android.test.*; import android.view.*; +import android.widget.Toast; import com.robotium.solo.*; @@ -118,18 +119,17 @@ public class testDashboardIntegration extends ActivityInstrumentationTestCase2 Date: Mon, 27 Apr 2015 18:08:59 +0200 Subject: Added a button to the UI Turn on VPN touching that button, and leave the image as a mere indicator. --- .../test/testDashboardIntegration.java | 36 +++++++++++++--------- 1 file changed, 21 insertions(+), 15 deletions(-) (limited to 'app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java') diff --git a/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java b/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java index 06fe0a42..18d7b45d 100644 --- a/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java +++ b/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java @@ -4,7 +4,7 @@ import android.content.*; import android.graphics.*; import android.test.*; import android.view.*; -import android.widget.Toast; +import android.widget.Button; import com.robotium.solo.*; @@ -46,19 +46,19 @@ public class testDashboardIntegration extends ActivityInstrumentationTestCase2 Date: Tue, 28 Apr 2015 13:48:20 +0200 Subject: Take screenshots of the changes. --- .../java/se/leap/bitmaskclient/test/testDashboardIntegration.java | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java') diff --git a/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java b/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java index 18d7b45d..13ca4431 100644 --- a/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java +++ b/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java @@ -30,6 +30,7 @@ public class testDashboardIntegration extends ActivityInstrumentationTestCase2 Date: Wed, 29 Apr 2015 12:25:24 +0200 Subject: Creating a user session fragment. I've separated the user session management to it, and encapsulated ProviderAPICommand into its own class. Putting the fragment statically in dashboard.xml isn't working, Android complains about it being duplicated, so I'm going to add it dynamically. --- .../test/testDashboardIntegration.java | 32 +++++++++------------- 1 file changed, 13 insertions(+), 19 deletions(-) (limited to 'app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java') diff --git a/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java b/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java index 13ca4431..262310bd 100644 --- a/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java +++ b/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java @@ -97,7 +97,7 @@ public class testDashboardIntegration extends ActivityInstrumentationTestCase2 Date: Wed, 29 Apr 2015 12:47:43 +0200 Subject: Dynamically load user session fragment. Tests click new button, instead of action bar's. Fixing more bugs... --- .../java/se/leap/bitmaskclient/test/testDashboardIntegration.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java') diff --git a/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java b/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java index 262310bd..7551091b 100644 --- a/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java +++ b/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java @@ -169,7 +169,11 @@ public class testDashboardIntegration extends ActivityInstrumentationTestCase2 Date: Thu, 30 Apr 2015 13:51:43 +0200 Subject: Works smoothly, correct texts. Next step: beautify. --- .../test/testDashboardIntegration.java | 32 ++++++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-) (limited to 'app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java') diff --git a/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java b/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java index 7551091b..a41a1acf 100644 --- a/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java +++ b/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java @@ -161,20 +161,25 @@ public class testDashboardIntegration extends ActivityInstrumentationTestCase2 Date: Fri, 1 May 2015 10:32:28 +0200 Subject: Separated tests for UserStatusFragment. This way, I can add more easily the tests for errors. --- .../test/testDashboardIntegration.java | 135 +++++---------------- 1 file changed, 27 insertions(+), 108 deletions(-) (limited to 'app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java') diff --git a/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java b/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java index a41a1acf..085e3c6b 100644 --- a/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java +++ b/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java @@ -1,9 +1,7 @@ package se.leap.bitmaskclient.test; -import android.content.*; import android.graphics.*; -import android.test.*; -import android.view.*; +import android.graphics.drawable.Drawable; import android.widget.Button; import com.robotium.solo.*; @@ -16,25 +14,12 @@ import mbanje.kurt.fabbutton.FabButton; import mbanje.kurt.fabbutton.ProgressRingView; import se.leap.bitmaskclient.*; -public class testDashboardIntegration extends ActivityInstrumentationTestCase2 { - - private Solo solo; - private Context context; - - public testDashboardIntegration() { - super(Dashboard.class); - } +public class testDashboardIntegration extends BaseTestDashboard { @Override protected void setUp() throws Exception { super.setUp(); - context = getInstrumentation().getContext(); - solo = new Solo(getInstrumentation(), getActivity()); Screenshot.initialize(solo); - ConnectionManager.setMobileDataEnabled(true, context); - solo.unlockScreen(); - if (solo.searchText(solo.getString(R.string.configuration_wizard_title))) - new testConfigurationWizard(solo).toDashboardAnonymously("demo.bitmask.net"); } @Override @@ -82,7 +67,7 @@ public class testDashboardIntegration extends ActivityInstrumentationTestCase2 Date: Fri, 1 May 2015 11:25:40 +0200 Subject: Separated tests for VpnFragment. --- .../test/testDashboardIntegration.java | 164 ++------------------- 1 file changed, 10 insertions(+), 154 deletions(-) (limited to 'app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java') diff --git a/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java b/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java index 085e3c6b..fea6bf77 100644 --- a/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java +++ b/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java @@ -16,138 +16,14 @@ import se.leap.bitmaskclient.*; public class testDashboardIntegration extends BaseTestDashboard { - @Override - protected void setUp() throws Exception { - super.setUp(); - Screenshot.initialize(solo); - } - @Override protected void tearDown() throws Exception { solo.finishOpenedActivities(); } - /** - * This test will fail if Android does not trust VPN connection. - * I cannot automate that dialog. - */ - public void testOnOffOpenVpn() { - Screenshot.take("Initial UI"); - clickVpnButton(); - Screenshot.setTimeToSleep(5); - Screenshot.takeWithSleep("Turning VPN on"); - turningEipOn(); - Screenshot.setTimeToSleep(0.5); - Screenshot.takeWithSleep("VPN turned on"); - - clickVpnButton(); - turningEipOff(); - Screenshot.take("VPN turned off"); - - clickVpnButton(); - turningEipOn(); - - clickVpnButton(); - turningEipOff(); - - /*clickVpnButton();; - turningEipOn(); - - turnNetworkOff(); - restartAdbServer(); // This doesn't work - */ - - } - - private void clickVpnButton() { - solo.clickOnView(getVpnButton()); - } - - private Button getVpnButton() { - return (Button) solo.getView(R.id.vpn_main_button); - } - - private FabButton getVpnWholeIcon() { - return (FabButton) solo.getView(R.id.vpn_Status_Image); - } - - private void turningEipOn() { - assertInProgress(); - int max_seconds_until_connected = 30; - - Condition condition = new Condition() { - @Override - public boolean isSatisfied() { - return iconConnected(); - } - }; - solo.waitForCondition(condition, max_seconds_until_connected * 1000); - sleepSeconds(2); - } - - private void assertInProgress() { - ProgressRingView a = (ProgressRingView) getVpnWholeIcon().findViewById(R.id.fabbutton_ring); - assertTrue(isShownWithinConfinesOfVisibleScreen(a)); - } - - private boolean iconConnected() { - return getVpnInsideIcon().equals(getDrawable(R.drawable.ic_stat_vpn)); - } - - private boolean iconDisconnected() { - return getVpnInsideIcon().equals(getDrawable(R.drawable.ic_stat_vpn_offline)); - } - - private Drawable getDrawable(int resId) { - return getActivity().getResources().getDrawable(resId); - } - - private Bitmap getVpnInsideIcon() { - CircleImageView a = (CircleImageView) getVpnWholeIcon().findViewById(R.id.fabbutton_circle); - a.setDrawingCacheEnabled(true); - return a.getDrawingCache(); - } - - private void turningEipOff() { - okToBrowserWarning(); - sayOkToDisconnect(); - - int max_seconds_until_connected = 1; - - Condition condition = new Condition() { - @Override - public boolean isSatisfied() { - return iconDisconnected(); - } - }; - solo.waitForCondition(condition, max_seconds_until_connected * 1000); - sleepSeconds(2); - } - - private void okToBrowserWarning() { - solo.waitForDialogToOpen(); - clickYes(); - } - - private void clickYes() { - String yes = solo.getString(android.R.string.yes); - solo.clickOnText(yes); - } - - private void sayOkToDisconnect() { - assertTrue(solo.waitForActivity(DisconnectVPN.class)); - clickYes(); - } - - private void turnNetworkOff() { - ConnectionManager.setMobileDataEnabled(false, context); - if (!solo.waitForText(getActivity().getString(R.string.eip_state_not_connected), 1, 15 * 1000)) - fail(); - } - - private void restartAdbServer() { - runAdbCommand("kill-server"); - runAdbCommand("start-server"); + public void testSwitchProvider() { + tapSwitchProvider(); + solo.goBack(); } public void testShowAbout() { @@ -168,35 +44,15 @@ public class testDashboardIntegration extends BaseTestDashboard { solo.clickOnMenuItem(menu_item); } - public void testSwitchProvider() { - tapSwitchProvider(); - solo.goBack(); - } - - public void testVpnEveryProvider() { - changeAndTestProvider("demo.bitmask.net"); - changeAndTestProvider("riseup.net"); - changeAndTestProvider("calyx.net"); - } - - private void changeAndTestProvider(String provider) { - changeProvider(provider); - sleepSeconds(1); - clickVpnButton(); - turningEipOn(); - clickVpnButton(); - turningEipOff(); - } - - private void sleepSeconds(int seconds) { - solo.sleep(seconds * 1000); + private void turnNetworkOff() { + ConnectionManager.setMobileDataEnabled(false, context); + if (!solo.waitForText(getActivity().getString(R.string.eip_state_not_connected), 1, 15 * 1000)) + fail(); } - public void testVpnIconIsDisplayed() { - assertTrue(isShownWithinConfinesOfVisibleScreen(getVpnWholeIcon())); - } - public void testVpnButtonIsDisplayed() { - assertTrue(isShownWithinConfinesOfVisibleScreen(getVpnButton())); + private void restartAdbServer() { + runAdbCommand("kill-server"); + runAdbCommand("start-server"); } /*public void testReboot() { -- cgit v1.2.3