OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "chrome/browser/history/android/bookmark_model_sql_handler.h" | 5 #include "chrome/browser/history/android/bookmark_model_sql_handler.h" |
6 | 6 |
7 #include "base/synchronization/waitable_event.h" | 7 #include "base/synchronization/waitable_event.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/bookmarks/bookmark_model.h" | 9 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 10 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
10 #include "chrome/browser/history/history_database.h" | 11 #include "chrome/browser/history/history_database.h" |
11 #include "chrome/browser/profiles/profile_manager.h" | 12 #include "chrome/browser/profiles/profile_manager.h" |
12 #include "chrome/common/chrome_constants.h" | 13 #include "chrome/common/chrome_constants.h" |
13 #include "chrome/test/base/testing_browser_process.h" | 14 #include "chrome/test/base/testing_browser_process.h" |
14 #include "chrome/test/base/testing_profile_manager.h" | 15 #include "chrome/test/base/testing_profile_manager.h" |
15 #include "chrome/test/base/testing_profile.h" | 16 #include "chrome/test/base/testing_profile.h" |
16 #include "chrome/test/base/ui_test_utils.h" | 17 #include "chrome/test/base/ui_test_utils.h" |
17 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
18 #include "content/public/test/test_browser_thread.h" | 19 #include "content/public/test/test_browser_thread.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 23 matching lines...) Expand all Loading... |
43 // could be found by ProfileManager::GetLastUsedProfile(). | 44 // could be found by ProfileManager::GetLastUsedProfile(). |
44 TestingProfile* testing_profile = profile_manager_.CreateTestingProfile( | 45 TestingProfile* testing_profile = profile_manager_.CreateTestingProfile( |
45 chrome::kInitialProfile); | 46 chrome::kInitialProfile); |
46 // Create the BookmarkModel that doesn't need to invoke load(). | 47 // Create the BookmarkModel that doesn't need to invoke load(). |
47 testing_profile->CreateBookmarkModel(true); | 48 testing_profile->CreateBookmarkModel(true); |
48 testing_profile->BlockUntilBookmarkModelLoaded(); | 49 testing_profile->BlockUntilBookmarkModelLoaded(); |
49 // Get the BookmarkModel from LastUsedProfile, this is the same way that | 50 // Get the BookmarkModel from LastUsedProfile, this is the same way that |
50 // how the BookmarkModelSQLHandler gets the BookmarkModel. | 51 // how the BookmarkModelSQLHandler gets the BookmarkModel. |
51 Profile* profile = ProfileManager::GetLastUsedProfile(); | 52 Profile* profile = ProfileManager::GetLastUsedProfile(); |
52 ASSERT_TRUE(profile); | 53 ASSERT_TRUE(profile); |
53 bookmark_model_ = profile->GetBookmarkModel(); | 54 bookmark_model_ = BookmarkModelFactory::GetForProfile(profile); |
54 ASSERT_TRUE(bookmark_model_); | 55 ASSERT_TRUE(bookmark_model_); |
55 | 56 |
56 // Create the directory for history database. | 57 // Create the directory for history database. |
57 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 58 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
58 FilePath history_db_name = temp_dir_.path().AppendASCII( | 59 FilePath history_db_name = temp_dir_.path().AppendASCII( |
59 chrome::kHistoryFilename); | 60 chrome::kHistoryFilename); |
60 history_db_.Init(history_db_name, temp_dir_.path()); | 61 history_db_.Init(history_db_name, temp_dir_.path()); |
61 } | 62 } |
62 | 63 |
63 // Runs the MessageLoopForUI, and return till all pending messages were | 64 // Runs the MessageLoopForUI, and return till all pending messages were |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 id_row.url = url1; | 240 id_row.url = url1; |
240 id_rows.clear(); | 241 id_rows.clear(); |
241 id_rows.push_back(id_row); | 242 id_rows.push_back(id_row); |
242 ASSERT_TRUE(handler.Delete(id_rows)); | 243 ASSERT_TRUE(handler.Delete(id_rows)); |
243 RunMessageLoopForUI(); | 244 RunMessageLoopForUI(); |
244 // All bookmarks were deleted. | 245 // All bookmarks were deleted. |
245 EXPECT_FALSE(bookmark_model_->HasBookmarks()); | 246 EXPECT_FALSE(bookmark_model_->HasBookmarks()); |
246 } | 247 } |
247 | 248 |
248 } // namespace history | 249 } // namespace history |
OLD | NEW |