| Index: chrome/browser/predictors/autocomplete_action_predictor_database_unittest.cc
|
| diff --git a/chrome/browser/autocomplete/network_action_predictor_database_unittest.cc b/chrome/browser/predictors/autocomplete_action_predictor_database_unittest.cc
|
| similarity index 52%
|
| rename from chrome/browser/autocomplete/network_action_predictor_database_unittest.cc
|
| rename to chrome/browser/predictors/autocomplete_action_predictor_database_unittest.cc
|
| index 0863dc8e0888c91b2f6ac12d7cd074e13a62c1f1..5d26efbed446ff5c5256b21330e68ba35930e339 100644
|
| --- a/chrome/browser/autocomplete/network_action_predictor_database_unittest.cc
|
| +++ b/chrome/browser/predictors/autocomplete_action_predictor_database_unittest.cc
|
| @@ -1,4 +1,4 @@
|
| -// Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| @@ -7,7 +7,7 @@
|
| #include "base/message_loop.h"
|
| #include "base/time.h"
|
| #include "base/utf_string_conversions.h"
|
| -#include "chrome/browser/autocomplete/network_action_predictor_database.h"
|
| +#include "chrome/browser/predictors/autocomplete_action_predictor_database.h"
|
| #include "chrome/test/base/testing_profile.h"
|
| #include "content/test/test_browser_thread.h"
|
| #include "sql/statement.h"
|
| @@ -20,16 +20,16 @@ using content::BrowserThread;
|
|
|
| namespace {
|
|
|
| -struct NetworkActionPredictorDatabase::Row test_db[] = {
|
| - NetworkActionPredictorDatabase::Row(
|
| +struct AutocompleteActionPredictorDatabase::Row test_db[] = {
|
| + AutocompleteActionPredictorDatabase::Row(
|
| "BD85DBA2-8C29-49F9-84AE-48E1E90880DF",
|
| ASCIIToUTF16("goog"), GURL("http://www.google.com/"),
|
| 1, 0),
|
| - NetworkActionPredictorDatabase::Row(
|
| + AutocompleteActionPredictorDatabase::Row(
|
| "BD85DBA2-8C29-49F9-84AE-48E1E90880E0",
|
| ASCIIToUTF16("slash"), GURL("http://slashdot.org/"),
|
| 3, 2),
|
| - NetworkActionPredictorDatabase::Row(
|
| + AutocompleteActionPredictorDatabase::Row(
|
| "BD85DBA2-8C29-49F9-84AE-48E1E90880E1",
|
| ASCIIToUTF16("news"), GURL("http://slashdot.org/"),
|
| 0, 1),
|
| @@ -37,10 +37,10 @@ struct NetworkActionPredictorDatabase::Row test_db[] = {
|
|
|
| } // end namespace
|
|
|
| -class NetworkActionPredictorDatabaseTest : public testing::Test {
|
| +class AutocompleteActionPredictorDatabaseTest : public testing::Test {
|
| public:
|
| - NetworkActionPredictorDatabaseTest();
|
| - virtual ~NetworkActionPredictorDatabaseTest();
|
| + AutocompleteActionPredictorDatabaseTest();
|
| + virtual ~AutocompleteActionPredictorDatabaseTest();
|
|
|
| virtual void SetUp();
|
| virtual void TearDown();
|
| @@ -49,15 +49,15 @@ class NetworkActionPredictorDatabaseTest : public testing::Test {
|
|
|
| void AddAll();
|
|
|
| - bool RowsAreEqual(const NetworkActionPredictorDatabase::Row& lhs,
|
| - const NetworkActionPredictorDatabase::Row& rhs) const;
|
| + bool RowsAreEqual(const AutocompleteActionPredictorDatabase::Row& lhs,
|
| + const AutocompleteActionPredictorDatabase::Row& rhs) const;
|
|
|
| TestingProfile* profile() { return &profile_; }
|
|
|
| protected:
|
|
|
| // Test functions that can be run against this text fixture or
|
| - // NetworkActionPredictorDatabaseReopenTest that inherits from this.
|
| + // AutocompleteActionPredictorDatabaseReopenTest that inherits from this.
|
| void TestAddRow();
|
| void TestGetRow();
|
| void TestUpdateRow();
|
| @@ -67,57 +67,59 @@ class NetworkActionPredictorDatabaseTest : public testing::Test {
|
|
|
| private:
|
| TestingProfile profile_;
|
| - scoped_refptr<NetworkActionPredictorDatabase> db_;
|
| + scoped_refptr<AutocompleteActionPredictorDatabase> db_;
|
| MessageLoop loop_;
|
| content::TestBrowserThread db_thread_;
|
| };
|
|
|
| -class NetworkActionPredictorDatabaseReopenTest
|
| - : public NetworkActionPredictorDatabaseTest {
|
| +class AutocompleteActionPredictorDatabaseReopenTest
|
| + : public AutocompleteActionPredictorDatabaseTest {
|
| public:
|
| virtual void SetUp() {
|
| // By calling SetUp twice, we make sure that the table already exists for
|
| // this fixture.
|
| - NetworkActionPredictorDatabaseTest::SetUp();
|
| - NetworkActionPredictorDatabaseTest::TearDown();
|
| - NetworkActionPredictorDatabaseTest::SetUp();
|
| + AutocompleteActionPredictorDatabaseTest::SetUp();
|
| + AutocompleteActionPredictorDatabaseTest::TearDown();
|
| + AutocompleteActionPredictorDatabaseTest::SetUp();
|
| }
|
| };
|
|
|
| -NetworkActionPredictorDatabaseTest::NetworkActionPredictorDatabaseTest()
|
| +AutocompleteActionPredictorDatabaseTest::
|
| +AutocompleteActionPredictorDatabaseTest()
|
| : loop_(MessageLoop::TYPE_DEFAULT),
|
| db_thread_(BrowserThread::DB, &loop_) {
|
| }
|
|
|
| -NetworkActionPredictorDatabaseTest::~NetworkActionPredictorDatabaseTest() {
|
| +AutocompleteActionPredictorDatabaseTest::
|
| +~AutocompleteActionPredictorDatabaseTest() {
|
| }
|
|
|
| -void NetworkActionPredictorDatabaseTest::SetUp() {
|
| - db_ = new NetworkActionPredictorDatabase(&profile_);
|
| +void AutocompleteActionPredictorDatabaseTest::SetUp() {
|
| + db_ = new AutocompleteActionPredictorDatabase(&profile_);
|
| db_->Initialize();
|
| }
|
|
|
| -void NetworkActionPredictorDatabaseTest::TearDown() {
|
| +void AutocompleteActionPredictorDatabaseTest::TearDown() {
|
| db_ = NULL;
|
| }
|
|
|
| -size_t NetworkActionPredictorDatabaseTest::CountRecords() const {
|
| +size_t AutocompleteActionPredictorDatabaseTest::CountRecords() const {
|
| sql::Statement s(db_->db_.GetUniqueStatement(
|
| "SELECT count(*) FROM network_action_predictor"));
|
| EXPECT_TRUE(s.Step());
|
| return static_cast<size_t>(s.ColumnInt(0));
|
| }
|
|
|
| -void NetworkActionPredictorDatabaseTest::AddAll() {
|
| +void AutocompleteActionPredictorDatabaseTest::AddAll() {
|
| for (size_t i = 0; i < arraysize(test_db); ++i)
|
| db_->AddRow(test_db[i]);
|
|
|
| EXPECT_EQ(arraysize(test_db), CountRecords());
|
| }
|
|
|
| -bool NetworkActionPredictorDatabaseTest::RowsAreEqual(
|
| - const NetworkActionPredictorDatabase::Row& lhs,
|
| - const NetworkActionPredictorDatabase::Row& rhs) const {
|
| +bool AutocompleteActionPredictorDatabaseTest::RowsAreEqual(
|
| + const AutocompleteActionPredictorDatabase::Row& lhs,
|
| + const AutocompleteActionPredictorDatabase::Row& rhs) const {
|
| return (lhs.id == rhs.id &&
|
| lhs.user_text == rhs.user_text &&
|
| lhs.url == rhs.url &&
|
| @@ -125,7 +127,7 @@ bool NetworkActionPredictorDatabaseTest::RowsAreEqual(
|
| lhs.number_of_misses == rhs.number_of_misses);
|
| }
|
|
|
| -void NetworkActionPredictorDatabaseTest::TestAddRow() {
|
| +void AutocompleteActionPredictorDatabaseTest::TestAddRow() {
|
| EXPECT_EQ(0U, CountRecords());
|
| db_->AddRow(test_db[0]);
|
| EXPECT_EQ(1U, CountRecords());
|
| @@ -135,22 +137,22 @@ void NetworkActionPredictorDatabaseTest::TestAddRow() {
|
| EXPECT_EQ(3U, CountRecords());
|
| }
|
|
|
| -void NetworkActionPredictorDatabaseTest::TestGetRow() {
|
| +void AutocompleteActionPredictorDatabaseTest::TestGetRow() {
|
| db_->AddRow(test_db[0]);
|
| - NetworkActionPredictorDatabase::Row row;
|
| + AutocompleteActionPredictorDatabase::Row row;
|
| db_->GetRow(test_db[0].id, &row);
|
| EXPECT_TRUE(RowsAreEqual(test_db[0], row))
|
| << "Expected: Row with id " << test_db[0].id << "\n"
|
| << "Got: Row with id " << row.id;
|
| }
|
|
|
| -void NetworkActionPredictorDatabaseTest::TestUpdateRow() {
|
| +void AutocompleteActionPredictorDatabaseTest::TestUpdateRow() {
|
| AddAll();
|
| - NetworkActionPredictorDatabase::Row row = test_db[1];
|
| + AutocompleteActionPredictorDatabase::Row row = test_db[1];
|
| row.number_of_hits = row.number_of_hits + 1;
|
| db_->UpdateRow(row);
|
|
|
| - NetworkActionPredictorDatabase::Row updated_row;
|
| + AutocompleteActionPredictorDatabase::Row updated_row;
|
| db_->GetRow(test_db[1].id, &updated_row);
|
|
|
| EXPECT_TRUE(RowsAreEqual(row, updated_row))
|
| @@ -158,77 +160,77 @@ void NetworkActionPredictorDatabaseTest::TestUpdateRow() {
|
| << "Got: Row with id " << updated_row.id;
|
| }
|
|
|
| -void NetworkActionPredictorDatabaseTest::TestDeleteRow() {
|
| +void AutocompleteActionPredictorDatabaseTest::TestDeleteRow() {
|
| AddAll();
|
| db_->DeleteRow(test_db[2].id);
|
| EXPECT_EQ(arraysize(test_db) - 1, CountRecords());
|
| }
|
|
|
| -void NetworkActionPredictorDatabaseTest::TestDeleteRows() {
|
| +void AutocompleteActionPredictorDatabaseTest::TestDeleteRows() {
|
| AddAll();
|
| - std::vector<NetworkActionPredictorDatabase::Row::Id> id_list;
|
| + std::vector<AutocompleteActionPredictorDatabase::Row::Id> id_list;
|
| id_list.push_back(test_db[0].id);
|
| id_list.push_back(test_db[2].id);
|
| db_->DeleteRows(id_list);
|
| EXPECT_EQ(arraysize(test_db) - 2, CountRecords());
|
|
|
| - NetworkActionPredictorDatabase::Row row;
|
| + AutocompleteActionPredictorDatabase::Row row;
|
| db_->GetRow(test_db[1].id, &row);
|
| EXPECT_TRUE(RowsAreEqual(test_db[1], row));
|
| }
|
|
|
| -void NetworkActionPredictorDatabaseTest::TestDeleteAllRows() {
|
| +void AutocompleteActionPredictorDatabaseTest::TestDeleteAllRows() {
|
| AddAll();
|
| db_->DeleteAllRows();
|
| EXPECT_EQ(0U, CountRecords());
|
| }
|
|
|
| -// NetworkActionPredictorDatabaseTest tests
|
| -TEST_F(NetworkActionPredictorDatabaseTest, AddRow) {
|
| +// AutocompleteActionPredictorDatabaseTest tests
|
| +TEST_F(AutocompleteActionPredictorDatabaseTest, AddRow) {
|
| TestAddRow();
|
| }
|
|
|
| -TEST_F(NetworkActionPredictorDatabaseTest, GetRow) {
|
| +TEST_F(AutocompleteActionPredictorDatabaseTest, GetRow) {
|
| TestGetRow();
|
| }
|
|
|
| -TEST_F(NetworkActionPredictorDatabaseTest, UpdateRow) {
|
| +TEST_F(AutocompleteActionPredictorDatabaseTest, UpdateRow) {
|
| TestUpdateRow();
|
| }
|
|
|
| -TEST_F(NetworkActionPredictorDatabaseTest, DeleteRow) {
|
| +TEST_F(AutocompleteActionPredictorDatabaseTest, DeleteRow) {
|
| TestDeleteRow();
|
| }
|
|
|
| -TEST_F(NetworkActionPredictorDatabaseTest, DeleteRows) {
|
| +TEST_F(AutocompleteActionPredictorDatabaseTest, DeleteRows) {
|
| TestDeleteRows();
|
| }
|
|
|
| -TEST_F(NetworkActionPredictorDatabaseTest, DeleteAllRows) {
|
| +TEST_F(AutocompleteActionPredictorDatabaseTest, DeleteAllRows) {
|
| TestDeleteAllRows();
|
| }
|
|
|
| -// NetworkActionPredictorDatabaseReopenTest tests
|
| -TEST_F(NetworkActionPredictorDatabaseReopenTest, AddRow) {
|
| +// AutocompleteActionPredictorDatabaseReopenTest tests
|
| +TEST_F(AutocompleteActionPredictorDatabaseReopenTest, AddRow) {
|
| TestAddRow();
|
| }
|
|
|
| -TEST_F(NetworkActionPredictorDatabaseReopenTest, GetRow) {
|
| +TEST_F(AutocompleteActionPredictorDatabaseReopenTest, GetRow) {
|
| TestGetRow();
|
| }
|
|
|
| -TEST_F(NetworkActionPredictorDatabaseReopenTest, UpdateRow) {
|
| +TEST_F(AutocompleteActionPredictorDatabaseReopenTest, UpdateRow) {
|
| TestUpdateRow();
|
| }
|
|
|
| -TEST_F(NetworkActionPredictorDatabaseReopenTest, DeleteRow) {
|
| +TEST_F(AutocompleteActionPredictorDatabaseReopenTest, DeleteRow) {
|
| TestDeleteRow();
|
| }
|
|
|
| -TEST_F(NetworkActionPredictorDatabaseReopenTest, DeleteRows) {
|
| +TEST_F(AutocompleteActionPredictorDatabaseReopenTest, DeleteRows) {
|
| TestDeleteRows();
|
| }
|
|
|
| -TEST_F(NetworkActionPredictorDatabaseReopenTest, DeleteAllRows) {
|
| +TEST_F(AutocompleteActionPredictorDatabaseReopenTest, DeleteAllRows) {
|
| TestDeleteAllRows();
|
| }
|
|
|