Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(678)

Side by Side Diff: chrome/browser/history/android/bookmark_model_sql_handler_unittest.cc

Issue 849323002: Componentize HistoryDatabase (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix android compilation Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "base/synchronization/waitable_event.h" 8 #include "base/synchronization/waitable_event.h"
9 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 9 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
10 #include "chrome/browser/history/history_database.h"
11 #include "chrome/browser/profiles/profile_manager.h" 10 #include "chrome/browser/profiles/profile_manager.h"
12 #include "chrome/common/chrome_constants.h" 11 #include "chrome/common/chrome_constants.h"
13 #include "chrome/test/base/testing_browser_process.h" 12 #include "chrome/test/base/testing_browser_process.h"
14 #include "chrome/test/base/testing_profile.h" 13 #include "chrome/test/base/testing_profile.h"
15 #include "chrome/test/base/testing_profile_manager.h" 14 #include "chrome/test/base/testing_profile_manager.h"
16 #include "components/bookmarks/browser/bookmark_model.h" 15 #include "components/bookmarks/browser/bookmark_model.h"
17 #include "components/bookmarks/test/bookmark_test_helpers.h" 16 #include "components/bookmarks/test/bookmark_test_helpers.h"
18 #include "components/history/core/browser/history_constants.h" 17 #include "components/history/core/browser/history_constants.h"
18 #include "components/history/core/browser/history_database.h"
19 #include "components/history/core/test/test_history_database.h"
19 #include "content/public/browser/browser_thread.h" 20 #include "content/public/browser/browser_thread.h"
20 #include "content/public/test/test_browser_thread.h" 21 #include "content/public/test/test_browser_thread.h"
21 #include "content/public/test/test_utils.h" 22 #include "content/public/test/test_utils.h"
22 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
23 24
24 using bookmarks::BookmarkModel; 25 using bookmarks::BookmarkModel;
25 using content::BrowserThread; 26 using content::BrowserThread;
26 27
27 namespace history { 28 namespace history {
28 29
29 class BookmarkModelSQLHandlerTest : public testing::Test { 30 class BookmarkModelSQLHandlerTest : public testing::Test {
30 public: 31 public:
31 BookmarkModelSQLHandlerTest() 32 BookmarkModelSQLHandlerTest()
32 : profile_manager_( 33 : profile_manager_(TestingBrowserProcess::GetGlobal()),
33 TestingBrowserProcess::GetGlobal()),
34 bookmark_model_(NULL), 34 bookmark_model_(NULL),
35 ui_thread_(BrowserThread::UI, &message_loop_), 35 ui_thread_(BrowserThread::UI, &message_loop_),
36 file_thread_(BrowserThread::FILE, &message_loop_) { 36 file_thread_(BrowserThread::FILE, &message_loop_) {}
37 }
38 virtual ~BookmarkModelSQLHandlerTest() {} 37 virtual ~BookmarkModelSQLHandlerTest() {}
39 38
40 protected: 39 protected:
41 virtual void SetUp() override { 40 virtual void SetUp() override {
42 // Setup the testing profile, so the bookmark_model_sql_handler could 41 // Setup the testing profile, so the bookmark_model_sql_handler could
43 // get the bookmark model from it. 42 // get the bookmark model from it.
44 ASSERT_TRUE(profile_manager_.SetUp()); 43 ASSERT_TRUE(profile_manager_.SetUp());
45 // It seems that the name has to be chrome::kInitialProfile, so it 44 // It seems that the name has to be chrome::kInitialProfile, so it
46 // could be found by ProfileManager::GetLastUsedProfile(). 45 // could be found by ProfileManager::GetLastUsedProfile().
47 TestingProfile* testing_profile = profile_manager_.CreateTestingProfile( 46 TestingProfile* testing_profile = profile_manager_.CreateTestingProfile(
(...skipping 20 matching lines...) Expand all
68 void RunMessageLoopForUI() { 67 void RunMessageLoopForUI() {
69 content::RunAllPendingInMessageLoop(); 68 content::RunAllPendingInMessageLoop();
70 } 69 }
71 70
72 TestingProfileManager profile_manager_; 71 TestingProfileManager profile_manager_;
73 BookmarkModel* bookmark_model_; 72 BookmarkModel* bookmark_model_;
74 base::MessageLoopForUI message_loop_; 73 base::MessageLoopForUI message_loop_;
75 content::TestBrowserThread ui_thread_; 74 content::TestBrowserThread ui_thread_;
76 content::TestBrowserThread file_thread_; 75 content::TestBrowserThread file_thread_;
77 base::ScopedTempDir temp_dir_; 76 base::ScopedTempDir temp_dir_;
78 HistoryDatabase history_db_; 77 TestHistoryDatabase history_db_;
79 }; 78 };
80 79
81 TEST_F(BookmarkModelSQLHandlerTest, InsertIntoMobileFolder) { 80 TEST_F(BookmarkModelSQLHandlerTest, InsertIntoMobileFolder) {
82 HistoryAndBookmarkRow row; 81 HistoryAndBookmarkRow row;
83 row.set_raw_url("http://bookmark.com"); 82 row.set_raw_url("http://bookmark.com");
84 row.set_url(GURL("http://bookmark.com")); 83 row.set_url(GURL("http://bookmark.com"));
85 row.set_title(base::UTF8ToUTF16("Bookmark Title")); 84 row.set_title(base::UTF8ToUTF16("Bookmark Title"));
86 row.set_is_bookmark(true); 85 row.set_is_bookmark(true);
87 86
88 BookmarkModelSQLHandler handler(&history_db_); 87 BookmarkModelSQLHandler handler(&history_db_);
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 id_row.url = url1; 245 id_row.url = url1;
247 id_rows.clear(); 246 id_rows.clear();
248 id_rows.push_back(id_row); 247 id_rows.push_back(id_row);
249 ASSERT_TRUE(handler.Delete(id_rows)); 248 ASSERT_TRUE(handler.Delete(id_rows));
250 RunMessageLoopForUI(); 249 RunMessageLoopForUI();
251 // All bookmarks were deleted. 250 // All bookmarks were deleted.
252 EXPECT_FALSE(bookmark_model_->HasBookmarks()); 251 EXPECT_FALSE(bookmark_model_->HasBookmarks());
253 } 252 }
254 253
255 } // namespace history 254 } // namespace history
OLDNEW
« no previous file with comments | « chrome/browser/history/android/bookmark_model_sql_handler.h ('k') | chrome/browser/history/android/sqlite_cursor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698