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

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/gcore/MockConnectedTaskTest.java

Issue 1141283003: Upstream oodles of Chrome for Android code into Chromium. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: final patch? Created 5 years, 7 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
Index: chrome/android/javatests/src/org/chromium/chrome/browser/gcore/MockConnectedTaskTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/gcore/MockConnectedTaskTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/gcore/MockConnectedTaskTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..6fdea18b15b63a10ef55e8b7c96ed062b2b086aa
--- /dev/null
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/gcore/MockConnectedTaskTest.java
@@ -0,0 +1,89 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.chrome.browser.gcore;
+
+import android.test.suitebuilder.annotation.SmallTest;
+
+import junit.framework.TestCase;
+
+import org.chromium.base.test.util.Feature;
+import org.chromium.chrome.test.gcore.MockChromeGoogleApiClient;
+
+/** Tests for {@link ConnectedTask} */
+public class MockConnectedTaskTest extends TestCase {
+ private MockChromeGoogleApiClient mClient;
+ private MockConnectedTask<MockChromeGoogleApiClient> mTask;
+
+ @Override
+ protected void setUp() throws Exception {
+ mClient = new MockChromeGoogleApiClient();
+ mTask = new MockConnectedTask<>(mClient);
+ }
+
+ @SmallTest
+ @Feature({"GCore"})
+ public void testConnectionSuccess() {
+ mClient.setConnectionResult(true);
+
+ mTask.run();
+
+ mTask.assertDoWhenConnectedCalled(1);
+ mTask.assertCleanUpCalled(1);
+ mTask.assertNoOtherMethodsCalled();
+
+ mClient.assertConnectWithTimeoutCalled(1);
+ mClient.assertDisconnectCalled(1);
+ mClient.assertNoOtherMethodsCalled();
+ }
+
+ @SmallTest
+ @Feature({"GCore"})
+ public void testConnectionFailureWithGooglePlayServicesAvailable() {
+ mClient.setConnectionResult(false);
+ mClient.setIsGooglePlayServicesAvailable(true);
+
+ mTask.run();
+
+ mTask.assertRescheduleCalled(1);
+ mTask.assertNoOtherMethodsCalled();
+
+ mClient.assertConnectWithTimeoutCalled(1);
+ mClient.assertIsGooglePlayServicesAvailableCalled(1);
+ mClient.assertNoOtherMethodsCalled();
+ }
+
+ @SmallTest
+ @Feature({"GCore"})
+ public void testConnectionFailureWithGooglePlayServicesUnavailable() {
+ mClient.setConnectionResult(false);
+ mClient.setIsGooglePlayServicesAvailable(false);
+
+ mTask.run();
+
+ mTask.assertCleanUpCalled(1);
+ mTask.assertNoOtherMethodsCalled();
+
+ mClient.assertConnectWithTimeoutCalled(1);
+ mClient.assertIsGooglePlayServicesAvailableCalled(1);
+ mClient.assertNoOtherMethodsCalled();
+ }
+
+ @SmallTest
+ @Feature({"GCore"})
+ public void testRetryLimit() {
+ // Task rescheduled ConnectedTask.RETRY_NUMBER_LIMIT - 1 times.
+ for (int i = 0; i < ConnectedTask.RETRY_NUMBER_LIMIT - 1; i++) {
+ testConnectionFailureWithGooglePlayServicesAvailable();
+ }
+
+ mTask.run();
+
+ mTask.assertCleanUpCalled(1);
+ mTask.assertNoOtherMethodsCalled();
+
+ mClient.assertConnectWithTimeoutCalled(1);
+ mClient.assertNoOtherMethodsCalled();
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698