OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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.bookmarks; | 5 package org.chromium.chrome.browser.bookmarks; |
6 | 6 |
7 import android.test.UiThreadTest; | 7 import android.test.UiThreadTest; |
8 import android.test.suitebuilder.annotation.SmallTest; | 8 import android.test.suitebuilder.annotation.SmallTest; |
9 | 9 |
10 import org.chromium.base.ThreadUtils; | 10 import org.chromium.base.ThreadUtils; |
11 import org.chromium.base.test.util.Feature; | 11 import org.chromium.base.test.util.Feature; |
12 import org.chromium.chrome.browser.bookmarks.BookmarkBridge.BookmarkItem; | 12 import org.chromium.chrome.browser.bookmarks.BookmarkBridge.BookmarkItem; |
13 import org.chromium.chrome.browser.profiles.Profile; | 13 import org.chromium.chrome.browser.profiles.Profile; |
| 14 import org.chromium.chrome.test.util.BookmarkTestUtil; |
14 import org.chromium.components.bookmarks.BookmarkId; | 15 import org.chromium.components.bookmarks.BookmarkId; |
15 import org.chromium.content.browser.test.NativeLibraryTestBase; | 16 import org.chromium.content.browser.test.NativeLibraryTestBase; |
16 import org.chromium.content.browser.test.util.Criteria; | |
17 import org.chromium.content.browser.test.util.CriteriaHelper; | |
18 | 17 |
19 import java.util.ArrayList; | 18 import java.util.ArrayList; |
20 import java.util.Arrays; | 19 import java.util.Arrays; |
21 import java.util.HashMap; | 20 import java.util.HashMap; |
22 import java.util.List; | 21 import java.util.List; |
23 | 22 |
24 /** | 23 /** |
25 * Tests for bookmark bridge | 24 * Tests for bookmark bridge |
26 */ | 25 */ |
27 public class BookmarkBridgeTest extends NativeLibraryTestBase { | 26 public class BookmarkBridgeTest extends NativeLibraryTestBase { |
28 | 27 |
29 private BookmarkBridge mBookmarkBridge; | 28 private BookmarkBridge mBookmarkBridge; |
30 private BookmarkId mMobileNode; | 29 private BookmarkId mMobileNode; |
31 private BookmarkId mOtherNode; | 30 private BookmarkId mOtherNode; |
32 private BookmarkId mDesktopNode; | 31 private BookmarkId mDesktopNode; |
33 | 32 |
34 @Override | 33 @Override |
35 protected void setUp() throws Exception { | 34 protected void setUp() throws Exception { |
36 super.setUp(); | 35 super.setUp(); |
37 loadNativeLibraryAndInitBrowserProcess(); | 36 loadNativeLibraryAndInitBrowserProcess(); |
| 37 |
38 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 38 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
39 @Override | 39 @Override |
40 public void run() { | 40 public void run() { |
41 Profile profile = Profile.getLastUsedProfile(); | 41 Profile profile = Profile.getLastUsedProfile(); |
42 mBookmarkBridge = new BookmarkBridge(profile); | 42 mBookmarkBridge = new BookmarkBridge(profile); |
43 mBookmarkBridge.loadEmptyPartnerBookmarkShimForTesting(); | 43 mBookmarkBridge.loadEmptyPartnerBookmarkShimForTesting(); |
44 } | 44 } |
45 }); | 45 }); |
46 | 46 |
47 CriteriaHelper.pollForUIThreadCriteria(new Criteria() { | 47 BookmarkTestUtil.waitForBookmarkModelLoaded(); |
48 @Override | |
49 public boolean isSatisfied() { | |
50 return mBookmarkBridge.isBookmarkModelLoaded(); | |
51 } | |
52 }); | |
53 | |
54 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 48 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
55 @Override | 49 @Override |
56 public void run() { | 50 public void run() { |
57 mMobileNode = mBookmarkBridge.getMobileFolderId(); | 51 mMobileNode = mBookmarkBridge.getMobileFolderId(); |
58 mDesktopNode = mBookmarkBridge.getDesktopFolderId(); | 52 mDesktopNode = mBookmarkBridge.getDesktopFolderId(); |
59 mOtherNode = mBookmarkBridge.getOtherFolderId(); | 53 mOtherNode = mBookmarkBridge.getOtherFolderId(); |
60 } | 54 } |
61 }); | 55 }); |
62 } | 56 } |
63 | 57 |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 mBookmarkBridge.getBookmarkById(folder).isFolder()); | 210 mBookmarkBridge.getBookmarkById(folder).isFolder()); |
217 assertTrue("Returned list contained unexpected key: ", idToDepth.con
tainsKey(folder)); | 211 assertTrue("Returned list contained unexpected key: ", idToDepth.con
tainsKey(folder)); |
218 assertEquals(idToDepth.get(folder), depth); | 212 assertEquals(idToDepth.get(folder), depth); |
219 idToDepth.remove(folder); | 213 idToDepth.remove(folder); |
220 } | 214 } |
221 assertEquals(idToDepth.size(), 0); | 215 assertEquals(idToDepth.size(), 0); |
222 folderList.clear(); | 216 folderList.clear(); |
223 depthList.clear(); | 217 depthList.clear(); |
224 } | 218 } |
225 } | 219 } |
OLD | NEW |