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

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/gsa/GSAServiceClientTest.java

Issue 2477513004: android: Record the memory size of the GSA process. (Closed)
Patch Set: Address comments. Created 4 years, 1 month 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/java_sources.gni ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/javatests/src/org/chromium/chrome/browser/gsa/GSAServiceClientTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/gsa/GSAServiceClientTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/gsa/GSAServiceClientTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..bc278ca8c9ff2ea6b6d34fa5f352bc1cc4b9cf40
--- /dev/null
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/gsa/GSAServiceClientTest.java
@@ -0,0 +1,67 @@
+// Copyright 2016 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.gsa;
+
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.ServiceConnection;
+import android.os.IBinder;
+import android.test.InstrumentationTestCase;
+import android.test.suitebuilder.annotation.SmallTest;
+
+import org.chromium.base.Log;
+
+import java.util.concurrent.Semaphore;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicReference;
+
+/** Tests for GSAServiceClient. */
+public class GSAServiceClientTest extends InstrumentationTestCase {
+ private static final String TAG = "GSAServiceClientTest";
+
+ @SmallTest
+ public void testGetPssForService() throws Exception {
+ Context context = getInstrumentation().getTargetContext();
+
+ if (!GSAState.getInstance(context).isGsaAvailable()) {
+ Log.w(TAG, "GSA is not available");
+ return;
+ }
+
+ final AtomicReference<ComponentName> componentNameRef = new AtomicReference<>();
+ final Semaphore semaphore = new Semaphore(0);
+ Intent intent =
+ new Intent(GSAServiceClient.GSA_SERVICE).setPackage(GSAState.SEARCH_INTENT_PACKAGE);
+
+ ServiceConnection connection = new ServiceConnection() {
+ @Override
+ public void onServiceConnected(ComponentName name, IBinder service) {
+ componentNameRef.set(name);
+ semaphore.release();
+ }
+
+ @Override
+ public void onServiceDisconnected(ComponentName name) {}
+ };
+ context.bindService(intent, connection, Context.BIND_AUTO_CREATE);
+ try {
+ assertTrue("Timeout", semaphore.tryAcquire(10, TimeUnit.SECONDS));
+
+ int pss = GSAServiceClient.getPssForService(componentNameRef.get());
+ assertTrue(pss != GSAServiceClient.INVALID_PSS);
+ assertTrue(pss > 0);
+ } finally {
+ context.unbindService(connection);
+ }
+ }
+
+ @SmallTest
+ public void testGetPssForServiceServiceNotFound() throws Exception {
+ ComponentName componentName = new ComponentName("unknown.package.name", "UnknownClass");
+ int pss = GSAServiceClient.getPssForService(componentName);
+ assertTrue(pss == GSAServiceClient.INVALID_PSS);
+ }
+}
« no previous file with comments | « chrome/android/java_sources.gni ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698