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

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/engagement/SiteEngagementServiceTest.java

Issue 2553013002: Expose the Site Engagement Service to Java. (Closed)
Patch Set: Clean up. Fix desktop compile Created 4 years 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/engagement/SiteEngagementServiceTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/engagement/SiteEngagementServiceTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/engagement/SiteEngagementServiceTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..d1ae2916ca2dd739680e9aa9189469dc3338d417
--- /dev/null
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/engagement/SiteEngagementServiceTest.java
@@ -0,0 +1,53 @@
+// 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.engagement;
+
+import android.test.suitebuilder.annotation.MediumTest;
+
+import org.chromium.base.test.util.Feature;
+import org.chromium.chrome.browser.ChromeActivity;
+import org.chromium.chrome.test.ChromeActivityTestCaseBase;
+
+/**
+ * Test for the Site Engagement Service Java binding.
+ */
+public class SiteEngagementServiceTest extends ChromeActivityTestCaseBase<ChromeActivity> {
+
+ public SiteEngagementServiceTest() {
+ super(ChromeActivity.class);
+ }
+
+ /**
+ * Verify that setting the engagement score for a URL and reading it back it works.
+ */
+ @MediumTest
gone 2016/12/07 21:50:26 Don't think MediumTest is required nowadays; it's
dominickn 2016/12/08 01:03:54 The test runner errors out without the annotation:
+ @Feature({"Engagement"})
+ public void testSettingAndRetrievingScore() {
+ try {
+ runTestOnUiThread(new Runnable() {
gone 2016/12/07 21:50:26 Can you just use the @UiThreadTest annotation?
dominickn 2016/12/08 01:03:54 New annotation learned! \o/
+ @Override
+ public void run() {
+ final String url = "https://www.google.com";
+ SiteEngagementService service = SiteEngagementService.getForProfile(
+ getActivity().getActivityTab().getProfile());
+
+ assertEquals(0.0, service.getScore(url));
+ service.resetScoreForUrl(url, 5.0);
+ assertEquals(5.0, service.getScore(url));
+
+ service.resetScoreForUrl(url, 2.0);
+ assertEquals(2.0, service.getScore(url));
+ }
+ });
+ } catch (Throwable t) {
+ fail(t.getMessage());
+ }
+ }
+
+ @Override
+ public void startMainActivity() throws InterruptedException {
+ startMainActivityOnBlankPage();
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698