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

Side by Side Diff: chrome/browser/history/history_backend_unittest.cc

Issue 934083003: Cleanup HistoryService and HistoryBackend interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@android-backend-provider
Patch Set: Created 5 years, 10 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/history_backend.h" 5 #include "chrome/browser/history/history_backend.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 243
244 private: 244 private:
245 friend class HistoryBackendTestDelegate; 245 friend class HistoryBackendTestDelegate;
246 246
247 // testing::Test 247 // testing::Test
248 void SetUp() override { 248 void SetUp() override {
249 ClearFaviconChangedNotificationCounter(); 249 ClearFaviconChangedNotificationCounter();
250 if (!base::CreateNewTempDirectory(FILE_PATH_LITERAL("BackendTest"), 250 if (!base::CreateNewTempDirectory(FILE_PATH_LITERAL("BackendTest"),
251 &test_dir_)) 251 &test_dir_))
252 return; 252 return;
253 backend_ = new HistoryBackend( 253 backend_ = new HistoryBackend(new HistoryBackendTestDelegate(this),
254 test_dir_, new HistoryBackendTestDelegate(this), &history_client_); 254 &history_client_);
255 backend_->Init(std::string(), false, 255 backend_->Init(std::string(), false,
256 TestHistoryDatabaseParamsForPath(test_dir_)); 256 TestHistoryDatabaseParamsForPath(test_dir_));
257 } 257 }
258 258
259 void TearDown() override { 259 void TearDown() override {
260 if (backend_.get()) 260 if (backend_.get())
261 backend_->Closing(); 261 backend_->Closing();
262 backend_ = NULL; 262 backend_ = NULL;
263 mem_backend_.reset(); 263 mem_backend_.reset();
264 base::DeleteFile(test_dir_, true); 264 base::DeleteFile(test_dir_, true);
(...skipping 1292 matching lines...) Expand 10 before | Expand all | Expand 10 after
1557 old_history_path = old_history_path.AppendASCII("HistoryNoSource"); 1557 old_history_path = old_history_path.AppendASCII("HistoryNoSource");
1558 1558
1559 // Copy history database file to current directory so that it will be deleted 1559 // Copy history database file to current directory so that it will be deleted
1560 // in Teardown. 1560 // in Teardown.
1561 base::FilePath new_history_path(test_dir()); 1561 base::FilePath new_history_path(test_dir());
1562 base::DeleteFile(new_history_path, true); 1562 base::DeleteFile(new_history_path, true);
1563 base::CreateDirectory(new_history_path); 1563 base::CreateDirectory(new_history_path);
1564 base::FilePath new_history_file = new_history_path.Append(kHistoryFilename); 1564 base::FilePath new_history_file = new_history_path.Append(kHistoryFilename);
1565 ASSERT_TRUE(base::CopyFile(old_history_path, new_history_file)); 1565 ASSERT_TRUE(base::CopyFile(old_history_path, new_history_file));
1566 1566
1567 backend_ = new HistoryBackend( 1567 backend_ = new HistoryBackend(new HistoryBackendTestDelegate(this),
1568 new_history_path, new HistoryBackendTestDelegate(this), &history_client_); 1568 &history_client_);
1569 backend_->Init(std::string(), false, 1569 backend_->Init(std::string(), false,
1570 TestHistoryDatabaseParamsForPath(new_history_path)); 1570 TestHistoryDatabaseParamsForPath(new_history_path));
1571 backend_->Closing(); 1571 backend_->Closing();
1572 backend_ = NULL; 1572 backend_ = NULL;
1573 1573
1574 // Now the database should already be migrated. 1574 // Now the database should already be migrated.
1575 // Check version first. 1575 // Check version first.
1576 int cur_version = HistoryDatabase::GetCurrentVersion(); 1576 int cur_version = HistoryDatabase::GetCurrentVersion();
1577 sql::Connection db; 1577 sql::Connection db;
1578 ASSERT_TRUE(db.Open(new_history_file)); 1578 ASSERT_TRUE(db.Open(new_history_file));
(...skipping 1231 matching lines...) Expand 10 before | Expand all | Expand 10 after
2810 old_history = old_history_path.AppendASCII("HistoryNoDuration"); 2810 old_history = old_history_path.AppendASCII("HistoryNoDuration");
2811 2811
2812 // Copy history database file to current directory so that it will be deleted 2812 // Copy history database file to current directory so that it will be deleted
2813 // in Teardown. 2813 // in Teardown.
2814 base::FilePath new_history_path(test_dir()); 2814 base::FilePath new_history_path(test_dir());
2815 base::DeleteFile(new_history_path, true); 2815 base::DeleteFile(new_history_path, true);
2816 base::CreateDirectory(new_history_path); 2816 base::CreateDirectory(new_history_path);
2817 base::FilePath new_history_file = new_history_path.Append(kHistoryFilename); 2817 base::FilePath new_history_file = new_history_path.Append(kHistoryFilename);
2818 ASSERT_TRUE(base::CopyFile(old_history, new_history_file)); 2818 ASSERT_TRUE(base::CopyFile(old_history, new_history_file));
2819 2819
2820 backend_ = new HistoryBackend( 2820 backend_ = new HistoryBackend(new HistoryBackendTestDelegate(this),
2821 new_history_path, new HistoryBackendTestDelegate(this), &history_client_); 2821 &history_client_);
2822 backend_->Init(std::string(), false, 2822 backend_->Init(std::string(), false,
2823 TestHistoryDatabaseParamsForPath(new_history_path)); 2823 TestHistoryDatabaseParamsForPath(new_history_path));
2824 backend_->Closing(); 2824 backend_->Closing();
2825 backend_ = NULL; 2825 backend_ = NULL;
2826 2826
2827 // Now the history database should already be migrated. 2827 // Now the history database should already be migrated.
2828 2828
2829 // Check version in history database first. 2829 // Check version in history database first.
2830 int cur_version = HistoryDatabase::GetCurrentVersion(); 2830 int cur_version = HistoryDatabase::GetCurrentVersion();
2831 sql::Connection db; 2831 sql::Connection db;
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
3290 // Verify that the second term is no longer returned as result, and also check 3290 // Verify that the second term is no longer returned as result, and also check
3291 // at the low level that it is gone for good. The term corresponding to the 3291 // at the low level that it is gone for good. The term corresponding to the
3292 // first URLRow should not be affected. 3292 // first URLRow should not be affected.
3293 EXPECT_EQ(1u, GetNumberOfMatchingSearchTerms(kTestKeywordId, term1)); 3293 EXPECT_EQ(1u, GetNumberOfMatchingSearchTerms(kTestKeywordId, term1));
3294 EXPECT_EQ(0u, GetNumberOfMatchingSearchTerms(kTestKeywordId, term2)); 3294 EXPECT_EQ(0u, GetNumberOfMatchingSearchTerms(kTestKeywordId, term2));
3295 EXPECT_TRUE(mem_backend_->db()->GetKeywordSearchTermRow(row1.id(), NULL)); 3295 EXPECT_TRUE(mem_backend_->db()->GetKeywordSearchTermRow(row1.id(), NULL));
3296 EXPECT_FALSE(mem_backend_->db()->GetKeywordSearchTermRow(row2.id(), NULL)); 3296 EXPECT_FALSE(mem_backend_->db()->GetKeywordSearchTermRow(row2.id(), NULL));
3297 } 3297 }
3298 3298
3299 } // namespace history 3299 } // namespace history
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698