OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.chrome.browser.engagement; | 5 package org.chromium.chrome.browser.engagement; |
6 | 6 |
7 import android.support.test.filters.SmallTest; | 7 import android.support.test.filters.SmallTest; |
8 import android.test.UiThreadTest; | 8 import android.test.UiThreadTest; |
9 | 9 |
10 import org.chromium.base.test.util.Feature; | 10 import org.chromium.base.test.util.Feature; |
(...skipping 15 matching lines...) Expand all Loading... |
26 */ | 26 */ |
27 @SmallTest | 27 @SmallTest |
28 @UiThreadTest | 28 @UiThreadTest |
29 @Feature({"Engagement"}) | 29 @Feature({"Engagement"}) |
30 public void testSettingAndRetrievingScore() { | 30 public void testSettingAndRetrievingScore() { |
31 final String url = "https://www.google.com"; | 31 final String url = "https://www.google.com"; |
32 SiteEngagementService service = SiteEngagementService.getForProfile( | 32 SiteEngagementService service = SiteEngagementService.getForProfile( |
33 getActivity().getActivityTab().getProfile()); | 33 getActivity().getActivityTab().getProfile()); |
34 | 34 |
35 assertEquals(0.0, service.getScore(url)); | 35 assertEquals(0.0, service.getScore(url)); |
36 service.resetScoreForUrl(url, 5.0); | 36 service.resetBaseScoreForUrl(url, 5.0); |
37 assertEquals(5.0, service.getScore(url)); | 37 assertEquals(5.0, service.getScore(url)); |
38 | 38 |
39 service.resetScoreForUrl(url, 2.0); | 39 service.resetBaseScoreForUrl(url, 2.0); |
40 assertEquals(2.0, service.getScore(url)); | 40 assertEquals(2.0, service.getScore(url)); |
41 } | 41 } |
42 | 42 |
43 /** | 43 /** |
44 * Verify that repeatedly fetching and throwing away the SiteEngagementServi
ce works. | 44 * Verify that repeatedly fetching and throwing away the SiteEngagementServi
ce works. |
45 */ | 45 */ |
46 @SmallTest | 46 @SmallTest |
47 @UiThreadTest | 47 @UiThreadTest |
48 @Feature({"Engagement"}) | 48 @Feature({"Engagement"}) |
49 public void testRepeatedlyGettingService() { | 49 public void testRepeatedlyGettingService() { |
50 final String url = "https://www.google.com"; | 50 final String url = "https://www.google.com"; |
51 Profile profile = getActivity().getActivityTab().getProfile(); | 51 Profile profile = getActivity().getActivityTab().getProfile(); |
52 | 52 |
53 assertEquals(0.0, SiteEngagementService.getForProfile(profile).getScore(
url)); | 53 assertEquals(0.0, SiteEngagementService.getForProfile(profile).getScore(
url)); |
54 SiteEngagementService.getForProfile(profile).resetScoreForUrl(url, 5.0); | 54 SiteEngagementService.getForProfile(profile).resetBaseScoreForUrl(url, 5
.0); |
55 assertEquals(5.0, SiteEngagementService.getForProfile(profile).getScore(
url)); | 55 assertEquals(5.0, SiteEngagementService.getForProfile(profile).getScore(
url)); |
56 | 56 |
57 SiteEngagementService.getForProfile(profile).resetScoreForUrl(url, 2.0); | 57 SiteEngagementService.getForProfile(profile).resetBaseScoreForUrl(url, 2
.0); |
58 assertEquals(2.0, SiteEngagementService.getForProfile(profile).getScore(
url)); | 58 assertEquals(2.0, SiteEngagementService.getForProfile(profile).getScore(
url)); |
59 } | 59 } |
60 | 60 |
61 @Override | 61 @Override |
62 public void startMainActivity() throws InterruptedException { | 62 public void startMainActivity() throws InterruptedException { |
63 startMainActivityOnBlankPage(); | 63 startMainActivityOnBlankPage(); |
64 } | 64 } |
65 } | 65 } |
OLD | NEW |