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/android_provider_backend.h" | 5 #include "chrome/browser/history/android/android_provider_backend.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/scoped_temp_dir.h" | 12 #include "base/scoped_temp_dir.h" |
13 #include "base/stringprintf.h" | 13 #include "base/stringprintf.h" |
14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
15 #include "chrome/browser/bookmarks/bookmark_model.h" | 15 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 16 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
16 #include "chrome/browser/bookmarks/bookmark_service.h" | 17 #include "chrome/browser/bookmarks/bookmark_service.h" |
17 #include "chrome/browser/history/android/android_time.h" | 18 #include "chrome/browser/history/android/android_time.h" |
18 #include "chrome/browser/history/history_backend.h" | 19 #include "chrome/browser/history/history_backend.h" |
19 #include "chrome/browser/profiles/profile_manager.h" | 20 #include "chrome/browser/profiles/profile_manager.h" |
20 #include "chrome/common/chrome_constants.h" | 21 #include "chrome/common/chrome_constants.h" |
21 #include "chrome/common/chrome_notification_types.h" | 22 #include "chrome/common/chrome_notification_types.h" |
22 #include "chrome/test/base/testing_browser_process.h" | 23 #include "chrome/test/base/testing_browser_process.h" |
23 #include "chrome/test/base/testing_profile_manager.h" | 24 #include "chrome/test/base/testing_profile_manager.h" |
24 #include "chrome/test/base/testing_profile.h" | 25 #include "chrome/test/base/testing_profile.h" |
25 #include "chrome/test/base/ui_test_utils.h" | 26 #include "chrome/test/base/ui_test_utils.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 // It seems that the name has to be chrome::kInitialProfile, so it | 125 // It seems that the name has to be chrome::kInitialProfile, so it |
125 // could be found by ProfileManager::GetLastUsedProfile(). | 126 // could be found by ProfileManager::GetLastUsedProfile(). |
126 TestingProfile* testing_profile = profile_manager_.CreateTestingProfile( | 127 TestingProfile* testing_profile = profile_manager_.CreateTestingProfile( |
127 chrome::kInitialProfile); | 128 chrome::kInitialProfile); |
128 testing_profile->CreateBookmarkModel(true); | 129 testing_profile->CreateBookmarkModel(true); |
129 testing_profile->BlockUntilBookmarkModelLoaded(); | 130 testing_profile->BlockUntilBookmarkModelLoaded(); |
130 // Get the BookmarkModel from LastUsedProfile, this is the same way that | 131 // Get the BookmarkModel from LastUsedProfile, this is the same way that |
131 // how the BookmarkModelSQLHandler gets the BookmarkModel. | 132 // how the BookmarkModelSQLHandler gets the BookmarkModel. |
132 Profile* profile = ProfileManager::GetLastUsedProfile(); | 133 Profile* profile = ProfileManager::GetLastUsedProfile(); |
133 ASSERT_TRUE(profile); | 134 ASSERT_TRUE(profile); |
134 bookmark_model_ = profile->GetBookmarkModel(); | 135 bookmark_model_ = BookmarkModelFactory::GetForProfile(profile); |
135 ASSERT_TRUE(bookmark_model_); | 136 ASSERT_TRUE(bookmark_model_); |
136 | 137 |
137 // Setup the database directory and files. | 138 // Setup the database directory and files. |
138 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 139 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
139 | 140 |
140 history_db_name_ = temp_dir_.path().AppendASCII(chrome::kHistoryFilename); | 141 history_db_name_ = temp_dir_.path().AppendASCII(chrome::kHistoryFilename); |
141 thumbnail_db_name_ = temp_dir_.path().AppendASCII( | 142 thumbnail_db_name_ = temp_dir_.path().AppendASCII( |
142 chrome::kFaviconsFilename); | 143 chrome::kFaviconsFilename); |
143 android_cache_db_name_ = temp_dir_.path().AppendASCII( | 144 android_cache_db_name_ = temp_dir_.path().AppendASCII( |
144 "TestAndroidCache.db"); | 145 "TestAndroidCache.db"); |
(...skipping 1580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1725 // Query by folder=1, the row2 should returned. | 1726 // Query by folder=1, the row2 should returned. |
1726 statement.reset(backend->QueryHistoryAndBookmarks( | 1727 statement.reset(backend->QueryHistoryAndBookmarks( |
1727 projections, std::string("folder=1"), std::vector<string16>(), | 1728 projections, std::string("folder=1"), std::vector<string16>(), |
1728 std::string("url ASC"))); | 1729 std::string("url ASC"))); |
1729 ASSERT_TRUE(statement->statement()->Step()); | 1730 ASSERT_TRUE(statement->statement()->Step()); |
1730 EXPECT_EQ(row2.url(), GURL(statement->statement()->ColumnString(0))); | 1731 EXPECT_EQ(row2.url(), GURL(statement->statement()->ColumnString(0))); |
1731 EXPECT_FALSE(statement->statement()->Step()); | 1732 EXPECT_FALSE(statement->statement()->Step()); |
1732 } | 1733 } |
1733 | 1734 |
1734 } // namespace history | 1735 } // namespace history |
OLD | NEW |