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.customtabs; | 5 package org.chromium.chrome.browser.customtabs; |
6 | 6 |
7 import static org.chromium.base.test.util.Restriction.RESTRICTION_TYPE_NON_LOW_E
ND_DEVICE; | 7 import static org.chromium.base.test.util.Restriction.RESTRICTION_TYPE_NON_LOW_E
ND_DEVICE; |
8 | 8 |
9 import android.app.Activity; | 9 import android.app.Activity; |
10 import android.app.Application; | 10 import android.app.Application; |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 private static int sIdToIncrement = 1; | 108 private static int sIdToIncrement = 1; |
109 | 109 |
110 private CustomTabActivity mActivity; | 110 private CustomTabActivity mActivity; |
111 private String mTestPage; | 111 private String mTestPage; |
112 private String mTestPage2; | 112 private String mTestPage2; |
113 private EmbeddedTestServer mTestServer; | 113 private EmbeddedTestServer mTestServer; |
114 | 114 |
115 @Override | 115 @Override |
116 protected void setUp() throws Exception { | 116 protected void setUp() throws Exception { |
117 super.setUp(); | 117 super.setUp(); |
| 118 Context appContext = getInstrumentation().getTargetContext().getApplicat
ionContext(); |
118 mTestServer = EmbeddedTestServer.createAndStartFileServer( | 119 mTestServer = EmbeddedTestServer.createAndStartFileServer( |
119 getInstrumentation().getContext(), Environment.getExternalStorag
eDirectory()); | 120 appContext, Environment.getExternalStorageDirectory()); |
120 mTestPage = mTestServer.getURL(TEST_PAGE); | 121 mTestPage = mTestServer.getURL(TEST_PAGE); |
121 mTestPage2 = mTestServer.getURL(TEST_PAGE_2); | 122 mTestPage2 = mTestServer.getURL(TEST_PAGE_2); |
122 PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX, | 123 PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX, a
ppContext); |
123 getInstrumentation().getTargetContext().getApplicationContext())
; | 124 LibraryLoader.get(LibraryProcessType.PROCESS_BROWSER).ensureInitialized(
); |
124 LibraryLoader.get(LibraryProcessType.PROCESS_BROWSER) | |
125 .ensureInitialized(getInstrumentation().getTargetContext().getAp
plicationContext()); | |
126 } | 125 } |
127 | 126 |
128 @Override | 127 @Override |
129 protected void tearDown() throws Exception { | 128 protected void tearDown() throws Exception { |
130 mTestServer.stopAndDestroyServer(); | 129 mTestServer.stopAndDestroyServer(); |
131 | 130 |
132 // finish() is called on a non-UI thread by the testing harness. Must hi
de the menu | 131 // finish() is called on a non-UI thread by the testing harness. Must hi
de the menu |
133 // first, otherwise the UI is manipulated on a non-UI thread. | 132 // first, otherwise the UI is manipulated on a non-UI thread. |
134 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 133 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
135 @Override | 134 @Override |
(...skipping 22 matching lines...) Expand all Loading... |
158 } | 157 } |
159 | 158 |
160 /** | 159 /** |
161 * Add a bundle specifying a custom menu entry. | 160 * Add a bundle specifying a custom menu entry. |
162 * @param intent The intent to modify. | 161 * @param intent The intent to modify. |
163 * @return The pending intent associated with the menu entry. | 162 * @return The pending intent associated with the menu entry. |
164 */ | 163 */ |
165 private PendingIntent addMenuEntriesToIntent(Intent intent, int numEntries)
{ | 164 private PendingIntent addMenuEntriesToIntent(Intent intent, int numEntries)
{ |
166 PendingIntent pi = PendingIntent.getBroadcast(getInstrumentation().getTa
rgetContext(), 0, | 165 PendingIntent pi = PendingIntent.getBroadcast(getInstrumentation().getTa
rgetContext(), 0, |
167 new Intent(), 0); | 166 new Intent(), 0); |
168 ArrayList<Bundle> menuItems = new ArrayList<Bundle>(); | 167 ArrayList<Bundle> menuItems = new ArrayList<>(); |
169 for (int i = 0; i < numEntries; i++) { | 168 for (int i = 0; i < numEntries; i++) { |
170 Bundle bundle = new Bundle(); | 169 Bundle bundle = new Bundle(); |
171 bundle.putString(CustomTabsIntent.KEY_MENU_ITEM_TITLE, TEST_MENU_TIT
LE); | 170 bundle.putString(CustomTabsIntent.KEY_MENU_ITEM_TITLE, TEST_MENU_TIT
LE); |
172 bundle.putParcelable(CustomTabsIntent.KEY_PENDING_INTENT, pi); | 171 bundle.putParcelable(CustomTabsIntent.KEY_PENDING_INTENT, pi); |
173 menuItems.add(bundle); | 172 menuItems.add(bundle); |
174 } | 173 } |
175 intent.putParcelableArrayListExtra(CustomTabsIntent.EXTRA_MENU_ITEMS, me
nuItems); | 174 intent.putParcelableArrayListExtra(CustomTabsIntent.EXTRA_MENU_ITEMS, me
nuItems); |
176 return pi; | 175 return pi; |
177 } | 176 } |
178 | 177 |
(...skipping 1371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1550 if (jsonText.equalsIgnoreCase("null")) jsonText = ""; | 1549 if (jsonText.equalsIgnoreCase("null")) jsonText = ""; |
1551 value = jsonText; | 1550 value = jsonText; |
1552 } catch (InterruptedException | TimeoutException e) { | 1551 } catch (InterruptedException | TimeoutException e) { |
1553 e.printStackTrace(); | 1552 e.printStackTrace(); |
1554 return false; | 1553 return false; |
1555 } | 1554 } |
1556 return TextUtils.equals(mExpected, value); | 1555 return TextUtils.equals(mExpected, value); |
1557 } | 1556 } |
1558 } | 1557 } |
1559 } | 1558 } |
OLD | NEW |