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

Side by Side Diff: chrome/browser/predictors/resource_prefetch_predictor_tables_unittest.cc

Issue 2263243002: predictors: Store protobufs in the database. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix tests. Created 4 years, 4 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 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/run_loop.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 50
51 // Checks that the input PrefetchData are the same, although the resources 51 // Checks that the input PrefetchData are the same, although the resources
52 // can be in different order. 52 // can be in different order.
53 void TestPrefetchDataAreEqual(const PrefetchDataMap& lhs, 53 void TestPrefetchDataAreEqual(const PrefetchDataMap& lhs,
54 const PrefetchDataMap& rhs) const; 54 const PrefetchDataMap& rhs) const;
55 void TestResourceRowsAreEqual(const ResourceRows& lhs, 55 void TestResourceRowsAreEqual(const ResourceRows& lhs,
56 const ResourceRows& rhs) const; 56 const ResourceRows& rhs) const;
57 57
58 void AddKey(PrefetchDataMap* m, const std::string& key) const; 58 void AddKey(PrefetchDataMap* m, const std::string& key) const;
59 59
60 // Useful for debugging test. 60 static void LogResource(const ResourceRow& row) {
61 LOG(ERROR) << "\t\t" << row.resource_url << "\t" << row.resource_type
62 << "\t" << row.number_of_hits << "\t" << row.number_of_misses
63 << "\t" << row.consecutive_misses << "\t" << row.average_position
64 << "\t" << row.priority << "\t" << row.has_validators << "\t"
65 << row.always_revalidate << "\t" << row.score;
66 }
67
68 // Useful for debugging tests.
61 void PrintPrefetchData(const PrefetchData& data) const { 69 void PrintPrefetchData(const PrefetchData& data) const {
62 LOG(ERROR) << "[" << data.key_type << "," << data.primary_key 70 LOG(ERROR) << "[" << data.key_type << "," << data.primary_key
63 << "," << data.last_visit.ToInternalValue() << "]"; 71 << "," << data.last_visit.ToInternalValue() << "]";
64 for (ResourceRows::const_iterator it = data.resources.begin(); 72 for (const ResourceRow& resource : data.resources)
65 it != data.resources.end(); ++it) { 73 LogResource(resource);
66 LOG(ERROR) << "\t\t" << it->resource_url << "\t" << it->resource_type
67 << "\t" << it->number_of_hits << "\t" << it->number_of_misses
68 << "\t" << it->consecutive_misses << "\t"
69 << it->average_position << "\t" << it->priority << "\t"
70 << it->has_validators << "\t" << it->always_revalidate << "\t"
71 << it->score;
72 }
73 } 74 }
74 75
75 PrefetchDataMap test_url_data_; 76 PrefetchDataMap test_url_data_;
76 PrefetchDataMap test_host_data_; 77 PrefetchDataMap test_host_data_;
77 }; 78 };
78 79
79 class ResourcePrefetchPredictorTablesReopenTest 80 class ResourcePrefetchPredictorTablesReopenTest
80 : public ResourcePrefetchPredictorTablesTest { 81 : public ResourcePrefetchPredictorTablesTest {
81 public: 82 public:
82 void SetUp() override { 83 void SetUp() override {
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 419
419 TEST_F(ResourcePrefetchPredictorTablesReopenTest, DeleteSingleDataPoint) { 420 TEST_F(ResourcePrefetchPredictorTablesReopenTest, DeleteSingleDataPoint) {
420 TestDeleteSingleDataPoint(); 421 TestDeleteSingleDataPoint();
421 } 422 }
422 423
423 TEST_F(ResourcePrefetchPredictorTablesReopenTest, DeleteAllData) { 424 TEST_F(ResourcePrefetchPredictorTablesReopenTest, DeleteAllData) {
424 TestDeleteAllData(); 425 TestDeleteAllData();
425 } 426 }
426 427
427 } // namespace predictors 428 } // namespace predictors
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698