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

Side by Side Diff: chrome/android/javatests/src/org/chromium/chrome/browser/physicalweb/ListUrlsActivityTest.java

Issue 2108983002: Use ContextUtils in PhysicalWeb (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update tests to use new methods Created 4 years, 5 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
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/preferences/privacy/PrivacyPreferencesManager.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.physicalweb; 5 package org.chromium.chrome.browser.physicalweb;
6 6
7 import android.app.Instrumentation.ActivityMonitor; 7 import android.app.Instrumentation.ActivityMonitor;
8 import android.content.ComponentName; 8 import android.content.ComponentName;
9 import android.content.Context; 9 import android.content.Context;
10 import android.content.ContextWrapper; 10 import android.content.ContextWrapper;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 }, timeout, CriteriaHelper.DEFAULT_POLLING_INTERVAL); 58 }, timeout, CriteriaHelper.DEFAULT_POLLING_INTERVAL);
59 } 59 }
60 } 60 }
61 61
62 @Override 62 @Override
63 protected void setUp() throws Exception { 63 protected void setUp() throws Exception {
64 super.setUp(); 64 super.setUp();
65 mContext = getInstrumentation().getTargetContext(); 65 mContext = getInstrumentation().getTargetContext();
66 // Restore the onboarding state 66 // Restore the onboarding state
67 ContextUtils.getAppSharedPreferences().edit().putInt("physical_web", 2). apply(); 67 ContextUtils.getAppSharedPreferences().edit().putInt("physical_web", 2). apply();
68 UrlManager urlManager = UrlManager.getInstance(mContext); 68 UrlManager urlManager = UrlManager.getInstance();
69 mMockPwsClient = new MockPwsClient(); 69 mMockPwsClient = new MockPwsClient();
70 urlManager.overridePwsClientForTesting(mMockPwsClient); 70 urlManager.overridePwsClientForTesting(mMockPwsClient);
71 urlManager.overrideNotificationManagerForTesting(new MockNotificationMan agerProxy()); 71 urlManager.overrideNotificationManagerForTesting(new MockNotificationMan agerProxy());
72 } 72 }
73 73
74 @SmallTest 74 @SmallTest
75 public void testTapEntryOpensUrl() throws InterruptedException { 75 public void testTapEntryOpensUrl() throws InterruptedException {
76 // Ensure the Physical Web is enabled. 76 // Ensure the Physical Web is enabled.
77 PrivacyPreferencesManager prefsManager = PrivacyPreferencesManager.getIn stance(); 77 PrivacyPreferencesManager prefsManager = PrivacyPreferencesManager.getIn stance();
78 prefsManager.setPhysicalWebEnabled(true); 78 prefsManager.setPhysicalWebEnabled(true);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 ArrayList<View> entries = new ArrayList<>(); 149 ArrayList<View> entries = new ArrayList<>();
150 listView.findViewsWithText(entries, TITLE, View.FIND_VIEWS_WITH_TEXT); 150 listView.findViewsWithText(entries, TITLE, View.FIND_VIEWS_WITH_TEXT);
151 assertEquals(0, entries.size()); 151 assertEquals(0, entries.size());
152 } 152 }
153 153
154 public void addUrl(String url, String title, String desc) { 154 public void addUrl(String url, String title, String desc) {
155 ArrayList<PwsResult> results = new ArrayList<>(); 155 ArrayList<PwsResult> results = new ArrayList<>();
156 results.add(new PwsResult(url, url, null, title, desc)); 156 results.add(new PwsResult(url, url, null, title, desc));
157 mMockPwsClient.addPwsResults(results); 157 mMockPwsClient.addPwsResults(results);
158 mMockPwsClient.addPwsResults(results); 158 mMockPwsClient.addPwsResults(results);
159 UrlManager.getInstance(mContext).addUrl(url); 159 UrlManager.getInstance().addUrl(url);
160 getInstrumentation().waitForIdleSync(); 160 getInstrumentation().waitForIdleSync();
161 } 161 }
162 162
163 public ListUrlsActivity launchActivity() { 163 public ListUrlsActivity launchActivity() {
164 Intent intent = new Intent(Intent.ACTION_MAIN); 164 Intent intent = new Intent(Intent.ACTION_MAIN);
165 intent.setComponent(new ComponentName(mContext, ListUrlsActivity.class)) ; 165 intent.setComponent(new ComponentName(mContext, ListUrlsActivity.class)) ;
166 intent.addCategory(Intent.CATEGORY_LAUNCHER); 166 intent.addCategory(Intent.CATEGORY_LAUNCHER);
167 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 167 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
168 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 168 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
169 ActivityMonitor monitor = 169 ActivityMonitor monitor =
170 getInstrumentation().addMonitor(ListUrlsActivity.class.getName() , null, false); 170 getInstrumentation().addMonitor(ListUrlsActivity.class.getName() , null, false);
171 mContext.startActivity(intent); 171 mContext.startActivity(intent);
172 ListUrlsActivity activity = (ListUrlsActivity) monitor.waitForActivity() ; 172 ListUrlsActivity activity = (ListUrlsActivity) monitor.waitForActivity() ;
173 activity.overridePwsClientForTesting(mMockPwsClient); 173 activity.overridePwsClientForTesting(mMockPwsClient);
174 return activity; 174 return activity;
175 } 175 }
176 } 176 }
OLDNEW
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/preferences/privacy/PrivacyPreferencesManager.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698