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

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

Issue 568823003: Merge Android RetrieveWebappInformation and Extensions GetApplicationInfo. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@manifest_manager_content
Patch Set: Created 6 years, 3 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 | « no previous file | chrome/browser/android/shortcut_helper.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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; 5 package org.chromium.chrome.browser;
6 6
7 import android.content.Intent; 7 import android.content.Intent;
8 import android.test.FlakyTest; 8 import android.test.FlakyTest;
9 9
10 import org.chromium.base.test.util.UrlUtils; 10 import org.chromium.base.test.util.UrlUtils;
(...skipping 24 matching lines...) Expand all
35 + "<meta name=\"mobile-web-app-capable\" content=\"yes\" />" 35 + "<meta name=\"mobile-web-app-capable\" content=\"yes\" />"
36 + "<title>" + SECOND_WEBAPP_TITLE + "</title>" 36 + "<title>" + SECOND_WEBAPP_TITLE + "</title>"
37 + "</head><body>Webapp capable again</body></html>"); 37 + "</head><body>Webapp capable again</body></html>");
38 38
39 private static final String NORMAL_TITLE = "Plain shortcut"; 39 private static final String NORMAL_TITLE = "Plain shortcut";
40 private static final String NORMAL_HTML = UrlUtils.encodeHtmlDataUri( 40 private static final String NORMAL_HTML = UrlUtils.encodeHtmlDataUri(
41 "<html>" 41 "<html>"
42 + "<head><title>" + NORMAL_TITLE + "</title></head>" 42 + "<head><title>" + NORMAL_TITLE + "</title></head>"
43 + "<body>Not Webapp capable</body></html>"); 43 + "<body>Not Webapp capable</body></html>");
44 44
45 private static final String META_APP_NAME_TITLE = "Web application-name";
46 private static final String META_APP_NAME_HTML = UrlUtils.encodeHtmlDataUri(
47 "<html><head>"
48 + "<meta name=\"mobile-web-app-capable\" content=\"yes\" />"
49 + "<meta name=\"application-name\" content=\"" + META_APP_NAME_TITLE + "\">"
50 + "<title>Not the right title</title>"
51 + "</head><body>Webapp capable</body></html>");
52
45 private static class TestObserver implements ChromeShellApplicationObserver { 53 private static class TestObserver implements ChromeShellApplicationObserver {
46 Intent mFiredIntent; 54 Intent mFiredIntent;
47 55
48 @Override 56 @Override
49 public boolean onSendBroadcast(Intent intent) { 57 public boolean onSendBroadcast(Intent intent) {
50 if (intent.hasExtra(Intent.EXTRA_SHORTCUT_NAME)) { 58 if (intent.hasExtra(Intent.EXTRA_SHORTCUT_NAME)) {
51 // Stop a shortcut from really being added. 59 // Stop a shortcut from really being added.
52 mFiredIntent = intent; 60 mFiredIntent = intent;
53 return false; 61 return false;
54 } 62 }
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 * crbug.com/303486 154 * crbug.com/303486
147 */ 155 */
148 @FlakyTest 156 @FlakyTest
149 public void testAddWebappShortcutsWithTitleEdit() throws InterruptedExceptio n { 157 public void testAddWebappShortcutsWithTitleEdit() throws InterruptedExceptio n {
150 // Add a webapp shortcut to check edited title. 158 // Add a webapp shortcut to check edited title.
151 addShortcutToURL(WEBAPP_HTML, EDITED_WEBAPP_TITLE); 159 addShortcutToURL(WEBAPP_HTML, EDITED_WEBAPP_TITLE);
152 Intent firedIntent = mTestObserver.mFiredIntent; 160 Intent firedIntent = mTestObserver.mFiredIntent;
153 assertEquals(EDITED_WEBAPP_TITLE , firedIntent.getStringExtra(Intent.EXT RA_SHORTCUT_NAME)); 161 assertEquals(EDITED_WEBAPP_TITLE , firedIntent.getStringExtra(Intent.EXT RA_SHORTCUT_NAME));
154 } 162 }
155 163
164 /**
165 * @MediumTest
166 * @Feature("{Webapp}")
167 * crbug.com/303486
168 */
169 @FlakyTest
170 public void testAddWebappShortcutsWithApplicationName() throws InterruptedEx ception {
171 // Add a webapp shortcut to check edited title.
172 addShortcutToURL(META_APP_NAME_HTML, "");
173 Intent firedIntent = mTestObserver.mFiredIntent;
174 assertEquals(META_APP_NAME_TITLE , firedIntent.getStringExtra(Intent.EXT RA_SHORTCUT_NAME));
175 }
176
156 private void addShortcutToURL(String url, final String title) throws Interru ptedException { 177 private void addShortcutToURL(String url, final String title) throws Interru ptedException {
157 loadUrlWithSanitization(url); 178 loadUrlWithSanitization(url);
158 assertTrue(waitForActiveShellToBeDoneLoading()); 179 assertTrue(waitForActiveShellToBeDoneLoading());
159 180
160 // Add the shortcut. 181 // Add the shortcut.
161 getInstrumentation().runOnMainSync(new Runnable() { 182 getInstrumentation().runOnMainSync(new Runnable() {
162 @Override 183 @Override
163 public void run() { 184 public void run() {
164 final ShortcutHelper shortcutHelper = new ShortcutHelper( 185 final ShortcutHelper shortcutHelper = new ShortcutHelper(
165 mActivity.getApplicationContext(), mActivity.getActiveTa b()); 186 mActivity.getApplicationContext(), mActivity.getActiveTa b());
(...skipping 10 matching lines...) Expand all
176 197
177 // Make sure that the shortcut was added. 198 // Make sure that the shortcut was added.
178 assertTrue(CriteriaHelper.pollForCriteria(new Criteria() { 199 assertTrue(CriteriaHelper.pollForCriteria(new Criteria() {
179 @Override 200 @Override
180 public boolean isSatisfied() { 201 public boolean isSatisfied() {
181 return mTestObserver.mFiredIntent != null; 202 return mTestObserver.mFiredIntent != null;
182 } 203 }
183 })); 204 }));
184 } 205 }
185 } 206 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/android/shortcut_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698