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/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 ASSERT_TRUE(bookmark_model_); | 194 ASSERT_TRUE(bookmark_model_); |
195 | 195 |
196 // Get the BookmarkModel from LastUsedProfile, this is the same way that | 196 // Get the BookmarkModel from LastUsedProfile, this is the same way that |
197 // how the BookmarkModelSQLHandler gets the BookmarkModel. | 197 // how the BookmarkModelSQLHandler gets the BookmarkModel. |
198 Profile* profile = ProfileManager::GetLastUsedProfile(); | 198 Profile* profile = ProfileManager::GetLastUsedProfile(); |
199 ASSERT_TRUE(profile); | 199 ASSERT_TRUE(profile); |
200 | 200 |
201 // Setup the database directory and files. | 201 // Setup the database directory and files. |
202 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 202 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
203 | 203 |
204 history_db_name_ = temp_dir_.path().AppendASCII(kHistoryFilename); | 204 history_db_name_ = temp_dir_.GetPath().AppendASCII(kHistoryFilename); |
205 thumbnail_db_name_ = temp_dir_.path().AppendASCII(kFaviconsFilename); | 205 thumbnail_db_name_ = temp_dir_.GetPath().AppendASCII(kFaviconsFilename); |
206 android_cache_db_name_ = temp_dir_.path().AppendASCII( | 206 android_cache_db_name_ = |
207 "TestAndroidCache.db"); | 207 temp_dir_.GetPath().AppendASCII("TestAndroidCache.db"); |
208 } | 208 } |
209 | 209 |
210 void AddBookmark(const GURL& url) { | 210 void AddBookmark(const GURL& url) { |
211 const BookmarkNode* mobile_node = bookmark_model_->mobile_node(); | 211 const BookmarkNode* mobile_node = bookmark_model_->mobile_node(); |
212 ASSERT_TRUE(mobile_node); | 212 ASSERT_TRUE(mobile_node); |
213 ASSERT_TRUE(bookmark_model_->AddURL(mobile_node, 0, base::string16(), url)); | 213 ASSERT_TRUE(bookmark_model_->AddURL(mobile_node, 0, base::string16(), url)); |
214 } | 214 } |
215 | 215 |
216 bool GetAndroidURLsRows(std::vector<AndroidURLRow>* rows, | 216 bool GetAndroidURLsRows(std::vector<AndroidURLRow>* rows, |
217 AndroidProviderBackend* backend) { | 217 AndroidProviderBackend* backend) { |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 ASSERT_TRUE(bookmark_model_->AddURL(bookmark_model_->bookmark_bar_node(), 0, | 298 ASSERT_TRUE(bookmark_model_->AddURL(bookmark_model_->bookmark_bar_node(), 0, |
299 title3, url3)); | 299 title3, url3)); |
300 // Only use the HistoryBackend to generate the test data. | 300 // Only use the HistoryBackend to generate the test data. |
301 // HistoryBackend will shutdown after that. | 301 // HistoryBackend will shutdown after that. |
302 { | 302 { |
303 scoped_refptr<HistoryBackend> history_backend; | 303 scoped_refptr<HistoryBackend> history_backend; |
304 history_backend = new HistoryBackend(new AndroidProviderBackendDelegate(), | 304 history_backend = new HistoryBackend(new AndroidProviderBackendDelegate(), |
305 history_client_->CreateBackendClient(), | 305 history_client_->CreateBackendClient(), |
306 message_loop_.task_runner()); | 306 message_loop_.task_runner()); |
307 history_backend->Init(false, | 307 history_backend->Init(false, |
308 TestHistoryDatabaseParamsForPath(temp_dir_.path())); | 308 TestHistoryDatabaseParamsForPath(temp_dir_.GetPath())); |
309 history_backend->AddVisits(url1, visits1, history::SOURCE_SYNCED); | 309 history_backend->AddVisits(url1, visits1, history::SOURCE_SYNCED); |
310 history_backend->AddVisits(url2, visits2, history::SOURCE_SYNCED); | 310 history_backend->AddVisits(url2, visits2, history::SOURCE_SYNCED); |
311 URLRow url_row; | 311 URLRow url_row; |
312 | 312 |
313 ASSERT_TRUE(history_backend->GetURL(url1, &url_row)); | 313 ASSERT_TRUE(history_backend->GetURL(url1, &url_row)); |
314 url_id1 = url_row.id(); | 314 url_id1 = url_row.id(); |
315 ASSERT_TRUE(history_backend->GetURL(url2, &url_row)); | 315 ASSERT_TRUE(history_backend->GetURL(url2, &url_row)); |
316 url_id2 = url_row.id(); | 316 url_id2 = url_row.id(); |
317 | 317 |
318 // Set favicon to url2. | 318 // Set favicon to url2. |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 visits2.push_back(VisitInfo(last_visited2, ui::PAGE_TRANSITION_LINK)); | 434 visits2.push_back(VisitInfo(last_visited2, ui::PAGE_TRANSITION_LINK)); |
435 | 435 |
436 // Only use the HistoryBackend to generate the test data. | 436 // Only use the HistoryBackend to generate the test data. |
437 // HistoryBackend will shutdown after that. | 437 // HistoryBackend will shutdown after that. |
438 { | 438 { |
439 scoped_refptr<HistoryBackend> history_backend; | 439 scoped_refptr<HistoryBackend> history_backend; |
440 history_backend = new HistoryBackend(new AndroidProviderBackendDelegate(), | 440 history_backend = new HistoryBackend(new AndroidProviderBackendDelegate(), |
441 history_client_->CreateBackendClient(), | 441 history_client_->CreateBackendClient(), |
442 message_loop_.task_runner()); | 442 message_loop_.task_runner()); |
443 history_backend->Init(false, | 443 history_backend->Init(false, |
444 TestHistoryDatabaseParamsForPath(temp_dir_.path())); | 444 TestHistoryDatabaseParamsForPath(temp_dir_.GetPath())); |
445 history_backend->AddVisits(url1, visits1, history::SOURCE_SYNCED); | 445 history_backend->AddVisits(url1, visits1, history::SOURCE_SYNCED); |
446 history_backend->AddVisits(url2, visits2, history::SOURCE_SYNCED); | 446 history_backend->AddVisits(url2, visits2, history::SOURCE_SYNCED); |
447 | 447 |
448 history::URLRows url_rows(2u); | 448 history::URLRows url_rows(2u); |
449 ASSERT_TRUE(history_backend->GetURL(url1, &url_rows[0])); | 449 ASSERT_TRUE(history_backend->GetURL(url1, &url_rows[0])); |
450 ASSERT_TRUE(history_backend->GetURL(url2, &url_rows[1])); | 450 ASSERT_TRUE(history_backend->GetURL(url2, &url_rows[1])); |
451 url_rows[0].set_title(title1); | 451 url_rows[0].set_title(title1); |
452 url_rows[1].set_title(title2); | 452 url_rows[1].set_title(title2); |
453 ASSERT_EQ(2u, history_backend->UpdateURLs(url_rows)); | 453 ASSERT_EQ(2u, history_backend->UpdateURLs(url_rows)); |
454 | 454 |
(...skipping 1367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1822 visits2.push_back(VisitInfo(last_visited2, ui::PAGE_TRANSITION_LINK)); | 1822 visits2.push_back(VisitInfo(last_visited2, ui::PAGE_TRANSITION_LINK)); |
1823 | 1823 |
1824 // Only use the HistoryBackend to generate the test data. | 1824 // Only use the HistoryBackend to generate the test data. |
1825 // HistoryBackend will shutdown after that. | 1825 // HistoryBackend will shutdown after that. |
1826 { | 1826 { |
1827 scoped_refptr<HistoryBackend> history_backend; | 1827 scoped_refptr<HistoryBackend> history_backend; |
1828 history_backend = new HistoryBackend(new AndroidProviderBackendDelegate(), | 1828 history_backend = new HistoryBackend(new AndroidProviderBackendDelegate(), |
1829 history_client_->CreateBackendClient(), | 1829 history_client_->CreateBackendClient(), |
1830 message_loop_.task_runner()); | 1830 message_loop_.task_runner()); |
1831 history_backend->Init(false, | 1831 history_backend->Init(false, |
1832 TestHistoryDatabaseParamsForPath(temp_dir_.path())); | 1832 TestHistoryDatabaseParamsForPath(temp_dir_.GetPath())); |
1833 history_backend->AddVisits(url1, visits1, history::SOURCE_SYNCED); | 1833 history_backend->AddVisits(url1, visits1, history::SOURCE_SYNCED); |
1834 history_backend->AddVisits(url2, visits2, history::SOURCE_SYNCED); | 1834 history_backend->AddVisits(url2, visits2, history::SOURCE_SYNCED); |
1835 URLRow url_row; | 1835 URLRow url_row; |
1836 | 1836 |
1837 history::URLRows url_rows(2u); | 1837 history::URLRows url_rows(2u); |
1838 ASSERT_TRUE(history_backend->GetURL(url1, &url_rows[0])); | 1838 ASSERT_TRUE(history_backend->GetURL(url1, &url_rows[0])); |
1839 ASSERT_TRUE(history_backend->GetURL(url2, &url_rows[1])); | 1839 ASSERT_TRUE(history_backend->GetURL(url2, &url_rows[1])); |
1840 url_rows[0].set_title(title1); | 1840 url_rows[0].set_title(title1); |
1841 url_rows[1].set_title(title2); | 1841 url_rows[1].set_title(title2); |
1842 ASSERT_EQ(2u, history_backend->UpdateURLs(url_rows)); | 1842 ASSERT_EQ(2u, history_backend->UpdateURLs(url_rows)); |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2093 update_args, &update_count)); | 2093 update_args, &update_count)); |
2094 // Verify notifications. | 2094 // Verify notifications. |
2095 EXPECT_FALSE(notifier_.deleted_details()); | 2095 EXPECT_FALSE(notifier_.deleted_details()); |
2096 ASSERT_TRUE(notifier_.modified_details()); | 2096 ASSERT_TRUE(notifier_.modified_details()); |
2097 ASSERT_EQ(1u, notifier_.modified_details()->size()); | 2097 ASSERT_EQ(1u, notifier_.modified_details()->size()); |
2098 // No favicon will be updated as thumbnail database is missing. | 2098 // No favicon will be updated as thumbnail database is missing. |
2099 EXPECT_FALSE(notifier_.favicon_changed()); | 2099 EXPECT_FALSE(notifier_.favicon_changed()); |
2100 } | 2100 } |
2101 | 2101 |
2102 } // namespace history | 2102 } // namespace history |
OLD | NEW |