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

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

Issue 1749603002: Store URLs in WebappDataStorage, and purge them when history is cleared. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 9 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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.webapps; 5 package org.chromium.chrome.browser.webapps;
6 6
7 import android.app.Activity; 7 import android.app.Activity;
8 import android.content.Context; 8 import android.content.Context;
9 import android.content.Intent; 9 import android.content.Intent;
10 import android.content.SharedPreferences; 10 import android.content.SharedPreferences;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 * FLAG_ACTIVITY_NEW_DOCUMENT mechanism. Moreover, we don't have access to the task list pre-L so 48 * FLAG_ACTIVITY_NEW_DOCUMENT mechanism. Moreover, we don't have access to the task list pre-L so
49 * we have to assume that any non-running WebappActivities are not listed in And roid's Overview. 49 * we have to assume that any non-running WebappActivities are not listed in And roid's Overview.
50 */ 50 */
51 public class WebappModeTest extends MultiActivityTestBase { 51 public class WebappModeTest extends MultiActivityTestBase {
52 private static final String WEBAPP_1_ID = "webapp_id_1"; 52 private static final String WEBAPP_1_ID = "webapp_id_1";
53 private static final String WEBAPP_1_URL = UrlUtils.encodeHtmlDataUri( 53 private static final String WEBAPP_1_URL = UrlUtils.encodeHtmlDataUri(
54 "<html><head><title>Web app #1</title><meta name='viewport' " 54 "<html><head><title>Web app #1</title><meta name='viewport' "
55 + "content='width=device-width initial-scale=0.5, maximum-scale=0.5' ></head>" 55 + "content='width=device-width initial-scale=0.5, maximum-scale=0.5' ></head>"
56 + "<body bgcolor='#011684'>Webapp 1</body></html>"); 56 + "<body bgcolor='#011684'>Webapp 1</body></html>");
57 private static final String WEBAPP_1_TITLE = "Web app #1"; 57 private static final String WEBAPP_1_TITLE = "Web app #1";
58 private static final String WEBAPP_1_ORIGIN = "https://www.google.com";
58 59
59 private static final String WEBAPP_2_ID = "webapp_id_2"; 60 private static final String WEBAPP_2_ID = "webapp_id_2";
60 private static final String WEBAPP_2_URL = 61 private static final String WEBAPP_2_URL =
61 UrlUtils.encodeHtmlDataUri("<html><body bgcolor='#840116'>Webapp 2</ body></html>"); 62 UrlUtils.encodeHtmlDataUri("<html><body bgcolor='#840116'>Webapp 2</ body></html>");
62 private static final String WEBAPP_2_TITLE = "Web app #2"; 63 private static final String WEBAPP_2_TITLE = "Web app #2";
64 private static final String WEBAPP_2_ORIGIN = "http://google.com";
63 65
64 private static final String WEBAPP_ICON = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABC AIAAACQd1PeAAAACXB" 66 private static final String WEBAPP_ICON = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABC AIAAACQd1PeAAAACXB"
65 + "IWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3wQIFB4cxOfiSQAAABl0RVh0Q29tbWVu dABDcmVhdGVkIHdpdG" 67 + "IWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3wQIFB4cxOfiSQAAABl0RVh0Q29tbWVu dABDcmVhdGVkIHdpdG"
66 + "ggR0lNUFeBDhcAAAAMSURBVAjXY2AUawEAALcAnI/TkI8AAAAASUVORK5CYII="; 68 + "ggR0lNUFeBDhcAAAAMSURBVAjXY2AUawEAALcAnI/TkI8AAAAASUVORK5CYII=";
67 69
68 private void fireWebappIntent(String id, String url, String title, String ic on, 70 private void fireWebappIntent(String id, String url, String title, String ic on,
69 boolean addMac) throws Exception { 71 boolean addMac) throws Exception {
70 Intent intent = new Intent(); 72 Intent intent = new Intent();
71 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 73 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
72 intent.setPackage(getInstrumentation().getTargetContext().getPackageName ()); 74 intent.setPackage(getInstrumentation().getTargetContext().getPackageName ());
(...skipping 16 matching lines...) Expand all
89 ApplicationTestUtils.waitUntilChromeInForeground(); 91 ApplicationTestUtils.waitUntilChromeInForeground();
90 } 92 }
91 93
92 @Override 94 @Override
93 public void setUp() throws Exception { 95 public void setUp() throws Exception {
94 super.setUp(); 96 super.setUp();
95 97
96 // Register the webapps so when the data storage is opened, the test doe sn't crash. There is 98 // Register the webapps so when the data storage is opened, the test doe sn't crash. There is
97 // no race condition with the retrival as AsyncTasks are run sequentiall y on the background 99 // no race condition with the retrival as AsyncTasks are run sequentiall y on the background
98 // thread. 100 // thread.
99 WebappRegistry.registerWebapp(getInstrumentation().getTargetContext(), W EBAPP_1_ID); 101 WebappRegistry.registerWebapp(getInstrumentation().getTargetContext(), W EBAPP_1_ID,
100 WebappRegistry.registerWebapp(getInstrumentation().getTargetContext(), W EBAPP_2_ID); 102 WEBAPP_1_ORIGIN);
103 WebappRegistry.registerWebapp(getInstrumentation().getTargetContext(), W EBAPP_2_ID,
104 WEBAPP_2_ORIGIN);
101 } 105 }
102 106
103 /** 107 /**
104 * Tests that WebappActivities are started properly. 108 * Tests that WebappActivities are started properly.
105 */ 109 */
106 @MediumTest 110 @MediumTest
107 public void testWebappLaunches() throws Exception { 111 public void testWebappLaunches() throws Exception {
108 final WebappActivity firstActivity = 112 final WebappActivity firstActivity =
109 startWebappActivity(WEBAPP_1_ID, WEBAPP_1_URL, WEBAPP_1_TITLE, W EBAPP_ICON); 113 startWebappActivity(WEBAPP_1_ID, WEBAPP_1_URL, WEBAPP_1_TITLE, W EBAPP_ICON);
110 final int firstTabId = firstActivity.getActivityTab().getId(); 114 final int firstTabId = firstActivity.getActivityTab().getId();
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 354
351 WebappActivity webappActivity = (WebappActivity) lastActivity; 355 WebappActivity webappActivity = (WebappActivity) lastActivity;
352 if (webappActivity.getActivityTab() == null) return false; 356 if (webappActivity.getActivityTab() == null) return false;
353 357
354 View rootView = webappActivity.findViewById(android.R.id.content); 358 View rootView = webappActivity.findViewById(android.R.id.content);
355 if (!rootView.hasWindowFocus()) return false; 359 if (!rootView.hasWindowFocus()) return false;
356 360
357 return true; 361 return true;
358 } 362 }
359 } 363 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698