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; | 5 package org.chromium.chrome.browser; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.content.Intent; | 8 import android.content.Intent; |
9 import android.graphics.Bitmap; | 9 import android.graphics.Bitmap; |
10 import android.test.suitebuilder.annotation.SmallTest; | 10 import android.test.suitebuilder.annotation.SmallTest; |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 | 177 |
178 // Add the shortcut. | 178 // Add the shortcut. |
179 Callable<ShortcutHelper> callable = new Callable<ShortcutHelper>() { | 179 Callable<ShortcutHelper> callable = new Callable<ShortcutHelper>() { |
180 @Override | 180 @Override |
181 public ShortcutHelper call() { | 181 public ShortcutHelper call() { |
182 final ShortcutHelper helper = new ShortcutHelper( | 182 final ShortcutHelper helper = new ShortcutHelper( |
183 mActivity.getApplicationContext(), mActivity.getActivity
Tab()); | 183 mActivity.getApplicationContext(), mActivity.getActivity
Tab()); |
184 // Calling initialize() isn't strictly required but it is testin
g this code path. | 184 // Calling initialize() isn't strictly required but it is testin
g this code path. |
185 helper.initialize(new ShortcutHelper.ShortcutHelperObserver() { | 185 helper.initialize(new ShortcutHelper.ShortcutHelperObserver() { |
186 @Override | 186 @Override |
187 public void onTitleAvailable(String t) { | 187 public void onUserTitleAvailable(String t) { |
188 } | 188 } |
189 | 189 |
190 @Override | 190 @Override |
191 public void onIconAvailable(Bitmap icon) { | 191 public void onIconAvailable(Bitmap icon) { |
192 helper.addShortcut(title); | 192 helper.addShortcut(title); |
193 } | 193 } |
194 }); | 194 }); |
195 return helper; | 195 return helper; |
196 } | 196 } |
197 }; | 197 }; |
198 final ShortcutHelper helper = ThreadUtils.runOnUiThreadBlockingNoExcepti
on(callable); | 198 final ShortcutHelper helper = ThreadUtils.runOnUiThreadBlockingNoExcepti
on(callable); |
199 | 199 |
200 // Make sure that the shortcut was added. | 200 // Make sure that the shortcut was added. |
201 assertTrue(CriteriaHelper.pollForUIThreadCriteria(new Criteria() { | 201 assertTrue(CriteriaHelper.pollForUIThreadCriteria(new Criteria() { |
202 @Override | 202 @Override |
203 public boolean isSatisfied() { | 203 public boolean isSatisfied() { |
204 return mShortcutHelperDelegate.mBroadcastedIntent != null; | 204 return mShortcutHelperDelegate.mBroadcastedIntent != null; |
205 } | 205 } |
206 })); | 206 })); |
207 | 207 |
208 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 208 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
209 @Override | 209 @Override |
210 public void run() { | 210 public void run() { |
211 helper.destroy(); | 211 helper.destroy(); |
212 } | 212 } |
213 }); | 213 }); |
214 } | 214 } |
215 } | 215 } |
OLD | NEW |