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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package org.chromium.chrome.browser.gcore;
6
7 import android.test.suitebuilder.annotation.SmallTest;
8
9 import junit.framework.TestCase;
10
11 import org.chromium.base.test.util.Feature;
12 import org.chromium.chrome.test.gcore.MockChromeGoogleApiClient;
13
14 /** Tests for {@link ConnectedTask} */
15 public class MockConnectedTaskTest extends TestCase {
16 private MockChromeGoogleApiClient mClient;
17 private MockConnectedTask<MockChromeGoogleApiClient> mTask;
18
19 @Override
20 protected void setUp() throws Exception {
21 mClient = new MockChromeGoogleApiClient();
22 mTask = new MockConnectedTask<>(mClient);
23 }
24
25 @SmallTest
26 @Feature({"GCore"})
27 public void testConnectionSuccess() {
28 mClient.setConnectionResult(true);
29
30 mTask.run();
31
32 mTask.assertDoWhenConnectedCalled(1);
33 mTask.assertCleanUpCalled(1);
34 mTask.assertNoOtherMethodsCalled();
35
36 mClient.assertConnectWithTimeoutCalled(1);
37 mClient.assertDisconnectCalled(1);
38 mClient.assertNoOtherMethodsCalled();
39 }
40
41 @SmallTest
42 @Feature({"GCore"})
43 public void testConnectionFailureWithGooglePlayServicesAvailable() {
44 mClient.setConnectionResult(false);
45 mClient.setIsGooglePlayServicesAvailable(true);
46
47 mTask.run();
48
49 mTask.assertRescheduleCalled(1);
50 mTask.assertNoOtherMethodsCalled();
51
52 mClient.assertConnectWithTimeoutCalled(1);
53 mClient.assertIsGooglePlayServicesAvailableCalled(1);
54 mClient.assertNoOtherMethodsCalled();
55 }
56
57 @SmallTest
58 @Feature({"GCore"})
59 public void testConnectionFailureWithGooglePlayServicesUnavailable() {
60 mClient.setConnectionResult(false);
61 mClient.setIsGooglePlayServicesAvailable(false);
62
63 mTask.run();
64
65 mTask.assertCleanUpCalled(1);
66 mTask.assertNoOtherMethodsCalled();
67
68 mClient.assertConnectWithTimeoutCalled(1);
69 mClient.assertIsGooglePlayServicesAvailableCalled(1);
70 mClient.assertNoOtherMethodsCalled();
71 }
72
73 @SmallTest
74 @Feature({"GCore"})
75 public void testRetryLimit() {
76 // Task rescheduled ConnectedTask.RETRY_NUMBER_LIMIT - 1 times.
77 for (int i = 0; i < ConnectedTask.RETRY_NUMBER_LIMIT - 1; i++) {
78 testConnectionFailureWithGooglePlayServicesAvailable();
79 }
80
81 mTask.run();
82
83 mTask.assertCleanUpCalled(1);
84 mTask.assertNoOtherMethodsCalled();
85
86 mClient.assertConnectWithTimeoutCalled(1);
87 mClient.assertNoOtherMethodsCalled();
88 }
89 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698