| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <set> | 5 #include <set> |
| 6 #include <utility> | 6 #include <utility> |
| 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 "chrome/browser/predictors/predictor_database.h" | 12 #include "chrome/browser/predictors/predictor_database.h" |
| 12 #include "chrome/browser/predictors/resource_prefetch_predictor_tables.h" | 13 #include "chrome/browser/predictors/resource_prefetch_predictor_tables.h" |
| 13 #include "chrome/test/base/testing_profile.h" | 14 #include "chrome/test/base/testing_profile.h" |
| 14 #include "content/public/test/test_browser_thread.h" | 15 #include "content/public/test/test_browser_thread.h" |
| 15 #include "sql/statement.h" | 16 #include "sql/statement.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 17 | 18 |
| 18 namespace predictors { | 19 namespace predictors { |
| 19 | 20 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 | 76 |
| 76 class ResourcePrefetchPredictorTablesReopenTest | 77 class ResourcePrefetchPredictorTablesReopenTest |
| 77 : public ResourcePrefetchPredictorTablesTest { | 78 : public ResourcePrefetchPredictorTablesTest { |
| 78 public: | 79 public: |
| 79 void SetUp() override { | 80 void SetUp() override { |
| 80 // Write data to the table, and then reopen the db. | 81 // Write data to the table, and then reopen the db. |
| 81 ResourcePrefetchPredictorTablesTest::SetUp(); | 82 ResourcePrefetchPredictorTablesTest::SetUp(); |
| 82 ResourcePrefetchPredictorTablesTest::TearDown(); | 83 ResourcePrefetchPredictorTablesTest::TearDown(); |
| 83 | 84 |
| 84 db_.reset(new PredictorDatabase(&profile_)); | 85 db_.reset(new PredictorDatabase(&profile_)); |
| 85 loop_.RunUntilIdle(); | 86 base::RunLoop().RunUntilIdle(); |
| 86 tables_ = db_->resource_prefetch_tables(); | 87 tables_ = db_->resource_prefetch_tables(); |
| 87 } | 88 } |
| 88 }; | 89 }; |
| 89 | 90 |
| 90 ResourcePrefetchPredictorTablesTest::ResourcePrefetchPredictorTablesTest() | 91 ResourcePrefetchPredictorTablesTest::ResourcePrefetchPredictorTablesTest() |
| 91 : loop_(base::MessageLoop::TYPE_DEFAULT), | 92 : loop_(base::MessageLoop::TYPE_DEFAULT), |
| 92 db_thread_(content::BrowserThread::DB, &loop_), | 93 db_thread_(content::BrowserThread::DB, &loop_), |
| 93 db_(new PredictorDatabase(&profile_)), | 94 db_(new PredictorDatabase(&profile_)), |
| 94 tables_(db_->resource_prefetch_tables()) { | 95 tables_(db_->resource_prefetch_tables()) { |
| 95 loop_.RunUntilIdle(); | 96 base::RunLoop().RunUntilIdle(); |
| 96 } | 97 } |
| 97 | 98 |
| 98 ResourcePrefetchPredictorTablesTest::~ResourcePrefetchPredictorTablesTest() { | 99 ResourcePrefetchPredictorTablesTest::~ResourcePrefetchPredictorTablesTest() { |
| 99 } | 100 } |
| 100 | 101 |
| 101 void ResourcePrefetchPredictorTablesTest::SetUp() { | 102 void ResourcePrefetchPredictorTablesTest::SetUp() { |
| 102 tables_->DeleteAllData(); | 103 tables_->DeleteAllData(); |
| 103 InitializeSampleData(); | 104 InitializeSampleData(); |
| 104 } | 105 } |
| 105 | 106 |
| 106 void ResourcePrefetchPredictorTablesTest::TearDown() { | 107 void ResourcePrefetchPredictorTablesTest::TearDown() { |
| 107 tables_ = NULL; | 108 tables_ = NULL; |
| 108 db_.reset(); | 109 db_.reset(); |
| 109 loop_.RunUntilIdle(); | 110 base::RunLoop().RunUntilIdle(); |
| 110 } | 111 } |
| 111 | 112 |
| 112 void ResourcePrefetchPredictorTablesTest::TestGetAllData() { | 113 void ResourcePrefetchPredictorTablesTest::TestGetAllData() { |
| 113 PrefetchDataMap actual_url_data, actual_host_data; | 114 PrefetchDataMap actual_url_data, actual_host_data; |
| 114 tables_->GetAllData(&actual_url_data, &actual_host_data); | 115 tables_->GetAllData(&actual_url_data, &actual_host_data); |
| 115 | 116 |
| 116 TestPrefetchDataAreEqual(test_url_data_, actual_url_data); | 117 TestPrefetchDataAreEqual(test_url_data_, actual_url_data); |
| 117 TestPrefetchDataAreEqual(test_host_data_, actual_host_data); | 118 TestPrefetchDataAreEqual(test_host_data_, actual_host_data); |
| 118 } | 119 } |
| 119 | 120 |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 | 464 |
| 464 TEST_F(ResourcePrefetchPredictorTablesReopenTest, DeleteSingleDataPoint) { | 465 TEST_F(ResourcePrefetchPredictorTablesReopenTest, DeleteSingleDataPoint) { |
| 465 TestDeleteSingleDataPoint(); | 466 TestDeleteSingleDataPoint(); |
| 466 } | 467 } |
| 467 | 468 |
| 468 TEST_F(ResourcePrefetchPredictorTablesReopenTest, DeleteAllData) { | 469 TEST_F(ResourcePrefetchPredictorTablesReopenTest, DeleteAllData) { |
| 469 TestDeleteAllData(); | 470 TestDeleteAllData(); |
| 470 } | 471 } |
| 471 | 472 |
| 472 } // namespace predictors | 473 } // namespace predictors |
| OLD | NEW |