OLD | NEW |
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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 Intent intent = createIntent(id, url, title, icon, addMac); | 86 Intent intent = createIntent(id, url, title, icon, addMac); |
87 | 87 |
88 getInstrumentation().getTargetContext().startActivity(intent); | 88 getInstrumentation().getTargetContext().startActivity(intent); |
89 getInstrumentation().waitForIdleSync(); | 89 getInstrumentation().waitForIdleSync(); |
90 ApplicationTestUtils.waitUntilChromeInForeground(); | 90 ApplicationTestUtils.waitUntilChromeInForeground(); |
91 } | 91 } |
92 | 92 |
93 @Override | 93 @Override |
94 public void setUp() throws Exception { | 94 public void setUp() throws Exception { |
95 super.setUp(); | 95 super.setUp(); |
96 WebappRegistry.refreshSharedPrefsForTesting(); | |
97 | 96 |
98 // Register the webapps so when the data storage is opened, the test doe
sn't crash. There is | 97 // Register the webapps so when the data storage is opened, the test doe
sn't crash. There is |
99 // no race condition with the retrieval as AsyncTasks are run sequential
ly on the background | 98 // no race condition with the retrieval as AsyncTasks are run sequential
ly on the background |
100 // thread. | 99 // thread. |
101 WebappRegistry.getInstance().register( | 100 WebappRegistry.registerWebapp( |
102 WEBAPP_1_ID, new WebappRegistry.FetchWebappDataStorageCallback()
{ | 101 WEBAPP_1_ID, new WebappRegistry.FetchWebappDataStorageCallback()
{ |
103 @Override | 102 @Override |
104 public void onWebappDataStorageRetrieved(WebappDataStorage s
torage) { | 103 public void onWebappDataStorageRetrieved(WebappDataStorage s
torage) { |
105 storage.updateFromShortcutIntent(createIntent( | 104 storage.updateFromShortcutIntent(createIntent( |
106 WEBAPP_1_ID, WEBAPP_1_URL, WEBAPP_1_TITLE, WEBAP
P_ICON, true)); | 105 WEBAPP_1_ID, WEBAPP_1_URL, WEBAPP_1_TITLE, WEBAP
P_ICON, true)); |
107 } | 106 } |
108 }); | 107 }); |
109 WebappRegistry.getInstance().register( | 108 WebappRegistry.registerWebapp( |
110 WEBAPP_2_ID, new WebappRegistry.FetchWebappDataStorageCallback()
{ | 109 WEBAPP_2_ID, new WebappRegistry.FetchWebappDataStorageCallback()
{ |
111 @Override | 110 @Override |
112 public void onWebappDataStorageRetrieved(WebappDataStorage s
torage) { | 111 public void onWebappDataStorageRetrieved(WebappDataStorage s
torage) { |
113 storage.updateFromShortcutIntent(createIntent( | 112 storage.updateFromShortcutIntent(createIntent( |
114 WEBAPP_1_ID, WEBAPP_1_URL, WEBAPP_1_TITLE, WEBAP
P_ICON, true)); | 113 WEBAPP_1_ID, WEBAPP_1_URL, WEBAPP_1_TITLE, WEBAP
P_ICON, true)); |
115 } | 114 } |
116 }); | 115 }); |
117 } | 116 } |
118 | 117 |
119 /** | 118 /** |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 | 323 |
325 WebappActivity webappActivity = (WebappActivity) lastActivity; | 324 WebappActivity webappActivity = (WebappActivity) lastActivity; |
326 if (webappActivity.getActivityTab() == null) return false; | 325 if (webappActivity.getActivityTab() == null) return false; |
327 | 326 |
328 View rootView = webappActivity.findViewById(android.R.id.content); | 327 View rootView = webappActivity.findViewById(android.R.id.content); |
329 if (!rootView.hasWindowFocus()) return false; | 328 if (!rootView.hasWindowFocus()) return false; |
330 | 329 |
331 return true; | 330 return true; |
332 } | 331 } |
333 } | 332 } |
OLD | NEW |