| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/run_loop.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 11 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 12 #include "chrome/browser/predictors/autocomplete_action_predictor_table.h" | 13 #include "chrome/browser/predictors/autocomplete_action_predictor_table.h" |
| 13 #include "chrome/browser/predictors/predictor_database.h" | 14 #include "chrome/browser/predictors/predictor_database.h" |
| 14 #include "chrome/browser/predictors/predictor_database_factory.h" | 15 #include "chrome/browser/predictors/predictor_database_factory.h" |
| 15 #include "chrome/test/base/testing_profile.h" | 16 #include "chrome/test/base/testing_profile.h" |
| 16 #include "content/public/test/test_browser_thread.h" | 17 #include "content/public/test/test_browser_thread.h" |
| 17 #include "sql/statement.h" | 18 #include "sql/statement.h" |
| 18 | 19 |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 | 75 |
| 75 AutocompleteActionPredictorTableTest::AutocompleteActionPredictorTableTest() | 76 AutocompleteActionPredictorTableTest::AutocompleteActionPredictorTableTest() |
| 76 : db_thread_(BrowserThread::DB, &loop_) { | 77 : db_thread_(BrowserThread::DB, &loop_) { |
| 77 } | 78 } |
| 78 | 79 |
| 79 AutocompleteActionPredictorTableTest::~AutocompleteActionPredictorTableTest() { | 80 AutocompleteActionPredictorTableTest::~AutocompleteActionPredictorTableTest() { |
| 80 } | 81 } |
| 81 | 82 |
| 82 void AutocompleteActionPredictorTableTest::SetUp() { | 83 void AutocompleteActionPredictorTableTest::SetUp() { |
| 83 db_.reset(new PredictorDatabase(&profile_)); | 84 db_.reset(new PredictorDatabase(&profile_)); |
| 84 loop_.RunUntilIdle(); | 85 base::RunLoop().RunUntilIdle(); |
| 85 | 86 |
| 86 test_db_.push_back(AutocompleteActionPredictorTable::Row( | 87 test_db_.push_back(AutocompleteActionPredictorTable::Row( |
| 87 "BD85DBA2-8C29-49F9-84AE-48E1E90880DF", | 88 "BD85DBA2-8C29-49F9-84AE-48E1E90880DF", |
| 88 base::ASCIIToUTF16("goog"), GURL("http://www.google.com/"), | 89 base::ASCIIToUTF16("goog"), GURL("http://www.google.com/"), |
| 89 1, 0)); | 90 1, 0)); |
| 90 test_db_.push_back(AutocompleteActionPredictorTable::Row( | 91 test_db_.push_back(AutocompleteActionPredictorTable::Row( |
| 91 "BD85DBA2-8C29-49F9-84AE-48E1E90880E0", | 92 "BD85DBA2-8C29-49F9-84AE-48E1E90880E0", |
| 92 base::ASCIIToUTF16("slash"), GURL("http://slashdot.org/"), | 93 base::ASCIIToUTF16("slash"), GURL("http://slashdot.org/"), |
| 93 3, 2)); | 94 3, 2)); |
| 94 test_db_.push_back(AutocompleteActionPredictorTable::Row( | 95 test_db_.push_back(AutocompleteActionPredictorTable::Row( |
| 95 "BD85DBA2-8C29-49F9-84AE-48E1E90880E1", | 96 "BD85DBA2-8C29-49F9-84AE-48E1E90880E1", |
| 96 base::ASCIIToUTF16("news"), GURL("http://slashdot.org/"), | 97 base::ASCIIToUTF16("news"), GURL("http://slashdot.org/"), |
| 97 0, 1)); | 98 0, 1)); |
| 98 } | 99 } |
| 99 | 100 |
| 100 void AutocompleteActionPredictorTableTest::TearDown() { | 101 void AutocompleteActionPredictorTableTest::TearDown() { |
| 101 db_.reset(NULL); | 102 db_.reset(NULL); |
| 102 loop_.RunUntilIdle(); | 103 base::RunLoop().RunUntilIdle(); |
| 103 test_db_.clear(); | 104 test_db_.clear(); |
| 104 } | 105 } |
| 105 | 106 |
| 106 size_t AutocompleteActionPredictorTableTest::CountRecords() const { | 107 size_t AutocompleteActionPredictorTableTest::CountRecords() const { |
| 107 sql::Statement s(db_->GetDatabase()->GetUniqueStatement( | 108 sql::Statement s(db_->GetDatabase()->GetUniqueStatement( |
| 108 "SELECT count(*) FROM network_action_predictor")); | 109 "SELECT count(*) FROM network_action_predictor")); |
| 109 EXPECT_TRUE(s.Step()); | 110 EXPECT_TRUE(s.Step()); |
| 110 return static_cast<size_t>(s.ColumnInt(0)); | 111 return static_cast<size_t>(s.ColumnInt(0)); |
| 111 } | 112 } |
| 112 | 113 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 | 233 |
| 233 TEST_F(AutocompleteActionPredictorTableReopenTest, DeleteRows) { | 234 TEST_F(AutocompleteActionPredictorTableReopenTest, DeleteRows) { |
| 234 TestDeleteRows(); | 235 TestDeleteRows(); |
| 235 } | 236 } |
| 236 | 237 |
| 237 TEST_F(AutocompleteActionPredictorTableReopenTest, DeleteAllRows) { | 238 TEST_F(AutocompleteActionPredictorTableReopenTest, DeleteAllRows) { |
| 238 TestDeleteAllRows(); | 239 TestDeleteAllRows(); |
| 239 } | 240 } |
| 240 | 241 |
| 241 } // namespace predictors | 242 } // namespace predictors |
| OLD | NEW |