Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1567)

Unified Diff: chrome/android/junit/src/org/chromium/chrome/browser/omaha/ResponseParserTest.java

Issue 994283006: Add initial test and build files for Robolectric unit test suites. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed jbudorick's comments. Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/android/BUILD.gn ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/junit/src/org/chromium/chrome/browser/omaha/ResponseParserTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/omaha/ResponseParserTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/omaha/ResponseParserTest.java
similarity index 88%
copy from chrome/android/javatests/src/org/chromium/chrome/browser/omaha/ResponseParserTest.java
copy to chrome/android/junit/src/org/chromium/chrome/browser/omaha/ResponseParserTest.java
index 6ad87a99c89b773655fd5bbfb546adde854d180d..bb4dbefd2834da8e5ba134ad8e6a9d9f101266c6 100644
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/omaha/ResponseParserTest.java
+++ b/chrome/android/junit/src/org/chromium/chrome/browser/omaha/ResponseParserTest.java
@@ -4,11 +4,17 @@
package org.chromium.chrome.browser.omaha;
-import android.test.InstrumentationTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
import android.util.Xml;
import org.chromium.base.test.util.Feature;
+import org.chromium.testing.local.LocalRobolectricTestRunner;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import org.robolectric.annotation.Config;
+
import org.xmlpull.v1.XmlSerializer;
import java.io.IOException;
@@ -17,7 +23,9 @@ import java.io.StringWriter;
/**
* Unit tests for the Omaha ResponseParser.
*/
-public class ResponseParserTest extends InstrumentationTestCase {
+@RunWith(LocalRobolectricTestRunner.class)
+@Config(manifest = Config.NONE)
+public class ResponseParserTest {
// Note that the Omaha server appends "/" to the end of the URL codebase.
private static final String STRIPPED_URL =
"https://play.google.com/store/apps/details?id=com.google.android.apps.chrome";
@@ -102,11 +110,11 @@ public class ResponseParserTest extends InstrumentationTestCase {
serializer.endTag(null, "response");
serializer.endDocument();
} catch (IOException e) {
- fail("Caught an IOException creating the XML: " + e);
+ Assert.fail("Caught an IOException creating the XML: " + e);
} catch (IllegalArgumentException e) {
- fail("Caught an IllegalArgumentException creating the XML: " + e);
+ Assert.fail("Caught an IllegalArgumentException creating the XML: " + e);
} catch (IllegalStateException e) {
- fail("Caught an IllegalStateException creating the XML: " + e);
+ Assert.fail("Caught an IllegalStateException creating the XML: " + e);
}
return writer.toString();
@@ -190,15 +198,20 @@ public class ResponseParserTest extends InstrumentationTestCase {
new ResponseParser(true, "{APP_ID}", addInstall, addPing, updateStatus != null);
parser.parseResponse(xml);
- assertEquals("elapsed_seconds doesn't match.", 12345, parser.getDaystartSeconds());
- assertEquals("<app> status doesn't match.", appStatus, parser.getAppStatus());
- assertEquals("<updatecheck> status doesn't match.", updateStatus, parser.getUpdateStatus());
+ Assert.assertEquals("elapsed_seconds doesn't match.", 12345, parser.getDaystartSeconds());
+ Assert.assertEquals("<app> status doesn't match.", appStatus, parser.getAppStatus());
+ Assert.assertEquals(
+ "<updatecheck> status doesn't match.", updateStatus, parser.getUpdateStatus());
if (UPDATE_STATUS_OK.equals(updateStatus)) {
- assertEquals("Version number doesn't match.", "1.2.3.4", parser.getNewVersion());
- assertEquals("Market URL doesn't match.", STRIPPED_URL, parser.getURL());
+ Assert.assertEquals(
+ "Version number doesn't match.", "1.2.3.4", parser.getNewVersion());
+ Assert.assertEquals(
+ "Market URL doesn't match.", STRIPPED_URL, parser.getURL());
} else {
- assertEquals("Version number doesn't match.", null, parser.getNewVersion());
- assertEquals("Market URL doesn't match.", null, parser.getURL());
+ Assert.assertEquals(
+ "Version number doesn't match.", null, parser.getNewVersion());
+ Assert.assertEquals(
+ "Market URL doesn't match.", null, parser.getURL());
}
}
@@ -218,69 +231,69 @@ public class ResponseParserTest extends InstrumentationTestCase {
try {
parser.parseResponse(xml);
} catch (RequestFailureException e) {
- assertEquals("Incorrect error code received.", expectedErrorCode, e.errorCode);
+ Assert.assertEquals("Incorrect error code received.", expectedErrorCode, e.errorCode);
return;
}
- fail("Failed to throw RequestFailureException for bad XML.");
+ Assert.fail("Failed to throw RequestFailureException for bad XML.");
}
- @SmallTest
+ @Test
@Feature({"Omaha"})
public void testValidAllTypes() throws RequestFailureException {
runSuccessTest(APP_STATUS_OK, true, true, UPDATE_STATUS_OK);
}
- @SmallTest
+ @Test
@Feature({"Omaha"})
public void testValidNoInstall() throws RequestFailureException {
runSuccessTest(APP_STATUS_OK, false, true, UPDATE_STATUS_OK);
}
- @SmallTest
+ @Test
@Feature({"Omaha"})
public void testValidNoPing() throws RequestFailureException {
runSuccessTest(APP_STATUS_OK, true, false, UPDATE_STATUS_OK);
}
- @SmallTest
+ @Test
@Feature({"Omaha"})
public void testValidNoUpdatecheck() throws RequestFailureException {
runSuccessTest(APP_STATUS_OK, true, true, null);
}
- @SmallTest
+ @Test
@Feature({"Omaha"})
public void testValidUpdatecheckNoUpdate() throws RequestFailureException {
runSuccessTest(APP_STATUS_OK, false, false, UPDATE_STATUS_NOUPDATE);
}
- @SmallTest
+ @Test
@Feature({"Omaha"})
public void testValidUpdatecheckError() throws RequestFailureException {
runSuccessTest(APP_STATUS_OK, false, false, UPDATE_STATUS_ERROR);
}
- @SmallTest
+ @Test
@Feature({"Omaha"})
public void testValidUpdatecheckUnknown() throws RequestFailureException {
runSuccessTest(APP_STATUS_OK, false, false, UPDATE_STATUS_WTF);
}
- @SmallTest
+ @Test
@Feature({"Omaha"})
public void testValidAppStatusRestricted() throws RequestFailureException {
runSuccessTest(APP_STATUS_RESTRICTED, false, false, null);
}
- @SmallTest
+ @Test
@Feature({"Omaha"})
public void testFailBogusResponse() {
String xml = "Bogus";
runFailureTest(xml, RequestFailureException.ERROR_MALFORMED_XML, false, false, false);
}
- @SmallTest
+ @Test
@Feature({"Omaha"})
public void testBadResponseProtocol() {
String xml =
@@ -288,7 +301,7 @@ public class ResponseParserTest extends InstrumentationTestCase {
runFailureTest(xml, RequestFailureException.ERROR_PARSE_RESPONSE, false, false, false);
}
- @SmallTest
+ @Test
@Feature({"Omaha"})
public void testFailMissingDaystart() {
String xml =
@@ -296,7 +309,7 @@ public class ResponseParserTest extends InstrumentationTestCase {
runFailureTest(xml, RequestFailureException.ERROR_PARSE_DAYSTART, false, false, true);
}
- @SmallTest
+ @Test
@Feature({"Omaha"})
public void testAppTagMissingUpdatecheck() {
String xml =
@@ -304,7 +317,7 @@ public class ResponseParserTest extends InstrumentationTestCase {
runFailureTest(xml, RequestFailureException.ERROR_PARSE_UPDATECHECK, true, false, true);
}
- @SmallTest
+ @Test
@Feature({"Omaha"})
public void testAppTagUnexpectedUpdatecheck() {
String xml =
@@ -312,7 +325,7 @@ public class ResponseParserTest extends InstrumentationTestCase {
runFailureTest(xml, RequestFailureException.ERROR_PARSE_UPDATECHECK, true, false, false);
}
- @SmallTest
+ @Test
@Feature({"Omaha"})
public void testAppTagMissingPing() {
String xml =
@@ -320,7 +333,7 @@ public class ResponseParserTest extends InstrumentationTestCase {
runFailureTest(xml, RequestFailureException.ERROR_PARSE_PING, false, true, true);
}
- @SmallTest
+ @Test
@Feature({"Omaha"})
public void testAppTagUnexpectedPing() {
String xml =
@@ -328,7 +341,7 @@ public class ResponseParserTest extends InstrumentationTestCase {
runFailureTest(xml, RequestFailureException.ERROR_PARSE_PING, false, false, true);
}
- @SmallTest
+ @Test
@Feature({"Omaha"})
public void testAppTagMissingInstall() {
String xml =
@@ -336,7 +349,7 @@ public class ResponseParserTest extends InstrumentationTestCase {
runFailureTest(xml, RequestFailureException.ERROR_PARSE_EVENT, true, false, true);
}
- @SmallTest
+ @Test
@Feature({"Omaha"})
public void testAppTagUnexpectedInstall() {
String xml =
@@ -344,7 +357,7 @@ public class ResponseParserTest extends InstrumentationTestCase {
runFailureTest(xml, RequestFailureException.ERROR_PARSE_EVENT, false, false, true);
}
- @SmallTest
+ @Test
@Feature({"Omaha"})
public void testAppTagStatusError() {
String xml =
@@ -352,7 +365,7 @@ public class ResponseParserTest extends InstrumentationTestCase {
runFailureTest(xml, RequestFailureException.ERROR_PARSE_APP, false, false, false);
}
- @SmallTest
+ @Test
@Feature({"Omaha"})
public void testUpdatecheckMissingUrl() {
String xml = createTestXML(
« no previous file with comments | « chrome/android/BUILD.gn ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698