Index: libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/UpdateCheckTest.java |
=================================================================== |
--- a/libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/UpdateCheckTest.java |
+++ b/libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/UpdateCheckTest.java |
@@ -25,16 +25,18 @@ |
import org.adblockplus.libadblockplus.JsValue; |
import org.adblockplus.libadblockplus.LazyLogSystem; |
import org.adblockplus.libadblockplus.LazyWebRequest; |
import org.adblockplus.libadblockplus.ServerResponse; |
import org.adblockplus.libadblockplus.UpdateCheckDoneCallback; |
import org.junit.Test; |
+import java.io.File; |
+import java.io.IOException; |
import java.util.List; |
public class UpdateCheckTest extends BaseJsTest |
{ |
protected String previousRequestUrl; |
public class TestWebRequest extends LazyWebRequest |
{ |
@@ -76,21 +78,25 @@ |
@Override |
public void updateCheckDoneCallback(String error) |
{ |
updateCallbackCalled = true; |
updateError = error; |
} |
}; |
- public void reset() |
+ public void reset() throws IOException |
{ |
jsEngine = new JsEngine(appInfo); |
jsEngine.setLogSystem(new LazyLogSystem()); |
- jsEngine.setDefaultFileSystem(getContext().getFilesDir().getAbsolutePath()); |
+ |
+ cleanupFileSystem(); |
+ tmpFileSystemPath = buildTmpFileSystemPath(); |
+ jsEngine.setDefaultFileSystem(tmpFileSystemPath.getAbsolutePath()); |
+ |
jsEngine.setWebRequest(webRequest); |
jsEngine.setEventCallback("updateAvailable", eventCallback); |
filterEngine = new FilterEngine(jsEngine); |
} |
@Override |
protected void setUp() throws Exception |
@@ -105,17 +111,17 @@ |
} |
public void forceUpdateCheck() |
{ |
filterEngine.forceUpdateCheck(updateCallback); |
} |
@Test |
- public void testRequestFailure() throws InterruptedException |
+ public void testRequestFailure() throws InterruptedException, IOException |
{ |
webRequest.response.setStatus(ServerResponse.NsStatus.ERROR_FAILURE); |
appInfo = AppInfo |
.builder() |
.setName("1") |
.setVersion("3") |
.setApplication("4") |
@@ -148,17 +154,17 @@ |
"&platform=" + platform + |
"&platformVersion=" + platformVersion + |
"&lastVersion=0&downloadCount=0"; |
assertEquals(expectedUrl, previousRequestUrl); |
} |
@Test |
- public void testApplicationUpdateAvailable() throws InterruptedException |
+ public void testApplicationUpdateAvailable() throws InterruptedException, IOException |
{ |
webRequest.response.setStatus(ServerResponse.NsStatus.OK); |
webRequest.response.setResponseStatus(200); |
webRequest.response.setResponse( |
"{\"1/4\": {\"version\":\"3.1\",\"url\":\"https://foo.bar/\"}}"); |
appInfo = AppInfo |
.builder() |
@@ -178,17 +184,17 @@ |
assertNotNull(eventCallbackParams); |
assertEquals(1l, eventCallbackParams.size()); |
assertEquals("https://foo.bar/", eventCallbackParams.get(0).asString()); |
assertTrue(updateCallbackCalled); |
assertEquals("", updateError); |
} |
@Test |
- public void testWrongApplication() throws InterruptedException |
+ public void testWrongApplication() throws InterruptedException, IOException |
{ |
webRequest.response.setStatus(ServerResponse.NsStatus.OK); |
webRequest.response.setResponseStatus(200); |
webRequest.response.setResponse( |
"{\"1/3\": {\"version\":\"3.1\",\"url\":\"https://foo.bar/\"}}"); |
appInfo = AppInfo |
.builder() |
@@ -205,17 +211,17 @@ |
Thread.sleep(1000); |
assertFalse(eventCallbackCalled); |
assertTrue(updateCallbackCalled); |
assertEquals("", updateError); |
} |
@Test |
- public void testWrongVersion() throws InterruptedException |
+ public void testWrongVersion() throws InterruptedException, IOException |
{ |
webRequest.response.setStatus(ServerResponse.NsStatus.OK); |
webRequest.response.setResponseStatus(200); |
webRequest.response.setResponse( |
"{\"1\": {\"version\":\"3\",\"url\":\"https://foo.bar/\"}}"); |
appInfo = AppInfo |
.builder() |
@@ -232,17 +238,17 @@ |
Thread.sleep(1000); |
assertFalse(eventCallbackCalled); |
assertTrue(updateCallbackCalled); |
assertEquals("", updateError); |
} |
@Test |
- public void testWrongURL() throws InterruptedException |
+ public void testWrongURL() throws InterruptedException, IOException |
{ |
webRequest.response.setStatus(ServerResponse.NsStatus.OK); |
webRequest.response.setResponseStatus(200); |
webRequest.response.setResponse( |
"{\"1\": {\"version\":\"3.1\",\"url\":\"http://insecure/\"}}"); |
appInfo = AppInfo |
.builder() |