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

Unified Diff: chrome/test/android/javatests_staging/src/org/chromium/chrome/test/gcore/MockChromeGoogleApiClient.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/test/android/javatests_staging/src/org/chromium/chrome/test/gcore/MockChromeGoogleApiClient.java
diff --git a/chrome/test/android/javatests_staging/src/org/chromium/chrome/test/gcore/MockChromeGoogleApiClient.java b/chrome/test/android/javatests_staging/src/org/chromium/chrome/test/gcore/MockChromeGoogleApiClient.java
new file mode 100644
index 0000000000000000000000000000000000000000..ca22c6444493be7d38035d7cca18e5c3226e47a3
--- /dev/null
+++ b/chrome/test/android/javatests_staging/src/org/chromium/chrome/test/gcore/MockChromeGoogleApiClient.java
@@ -0,0 +1,91 @@
+// 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.test.gcore;
+
+import static junit.framework.Assert.assertEquals;
+
+import org.chromium.chrome.browser.gcore.ChromeGoogleApiClient;
+
+/**
+ * Mock of ChromeGoogleApiClient that tracks which methods are called.
+ */
+public class MockChromeGoogleApiClient implements ChromeGoogleApiClient {
+ private final Object mLock = new Object();
+
+ private boolean mConnectionResult;
+ private boolean mIsGooglePlayServicesAvailable;
+
+ private int mConnectWithTimeoutCount;
+ private int mDisconnectCount;
+ private int mIsGooglePlayServicesAvailableCount;
+
+ @Override
+ public boolean connectWithTimeout(long timeout) {
+ synchronized (mLock) {
+ mConnectWithTimeoutCount++;
+ return mConnectionResult;
+ }
+ }
+
+ @Override
+ public void disconnect() {
+ synchronized (mLock) {
+ mDisconnectCount++;
+ }
+ }
+
+ @Override
+ public boolean isGooglePlayServicesAvailable() {
+ synchronized (mLock) {
+ mIsGooglePlayServicesAvailableCount++;
+ return mIsGooglePlayServicesAvailable;
+ }
+ }
+
+ public void setConnectionResult(boolean result) {
+ synchronized (mLock) {
+ mConnectionResult = result;
+ }
+ }
+
+ public void setIsGooglePlayServicesAvailable(boolean available) {
+ synchronized (mLock) {
+ mIsGooglePlayServicesAvailable = available;
+ }
+ }
+
+ public void assertConnectWithTimeoutCalled(int times) {
+ synchronized (mLock) {
+ assertEquals(times, mConnectWithTimeoutCount);
+ mConnectWithTimeoutCount = 0;
+ }
+ }
+
+ public void assertDisconnectCalled(int times) {
+ synchronized (mLock) {
+ assertEquals(times, mDisconnectCount);
+ mDisconnectCount = 0;
+ }
+ }
+
+ public void assertIsGooglePlayServicesAvailableCalled(int times) {
+ synchronized (mLock) {
+ assertEquals(times, mIsGooglePlayServicesAvailableCount);
+ mIsGooglePlayServicesAvailableCount = 0;
+ }
+ }
+
+ public void assertNoOtherMethodsCalled() {
+ synchronized (mLock) {
+ assertEquals(0, mConnectWithTimeoutCount);
+ assertEquals(0, mDisconnectCount);
+ assertEquals(0, mIsGooglePlayServicesAvailableCount);
+ }
+ }
+
+ protected Object getLock() {
+ return mLock;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698