| 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 "chrome/browser/net/predictor.h" | 5 #include "chrome/browser/net/predictor.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 | 146 |
| 147 TEST_F(PredictorTest, StartupShutdownTest) { | 147 TEST_F(PredictorTest, StartupShutdownTest) { |
| 148 Predictor testing_master(true, true); | 148 Predictor testing_master(true, true); |
| 149 testing_master.Shutdown(); | 149 testing_master.Shutdown(); |
| 150 } | 150 } |
| 151 | 151 |
| 152 // Make sure nil referral lists really have no entries, and no latency listed. | 152 // Make sure nil referral lists really have no entries, and no latency listed. |
| 153 TEST_F(PredictorTest, ReferrerSerializationNilTest) { | 153 TEST_F(PredictorTest, ReferrerSerializationNilTest) { |
| 154 Predictor predictor(true, true); | 154 Predictor predictor(true, true); |
| 155 | 155 |
| 156 std::unique_ptr<base::ListValue> referral_list(NewEmptySerializationList()); | 156 std::unique_ptr<base::ListValue> referral_list(new base::ListValue); |
| 157 predictor.SerializeReferrers(referral_list.get()); | 157 predictor.SerializeReferrers(referral_list.get()); |
| 158 EXPECT_EQ(1U, referral_list->GetSize()); | 158 EXPECT_EQ(1U, referral_list->GetSize()); |
| 159 EXPECT_FALSE(GetDataFromSerialization( | 159 EXPECT_FALSE(GetDataFromSerialization( |
| 160 GURL("http://a.com:79"), GURL("http://b.com:78"), | 160 GURL("http://a.com:79"), GURL("http://b.com:78"), |
| 161 *referral_list.get(), NULL)); | 161 *referral_list.get(), NULL)); |
| 162 | 162 |
| 163 predictor.Shutdown(); | 163 predictor.Shutdown(); |
| 164 } | 164 } |
| 165 | 165 |
| 166 // Make sure that when a serialization list includes a value, that it can be | 166 // Make sure that when a serialization list includes a value, that it can be |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 TEST_F(PredictorTest, DiscardPredictorResults) { | 378 TEST_F(PredictorTest, DiscardPredictorResults) { |
| 379 SimplePredictor predictor(true, true); | 379 SimplePredictor predictor(true, true); |
| 380 base::ListValue referral_list; | 380 base::ListValue referral_list; |
| 381 predictor.SerializeReferrers(&referral_list); | 381 predictor.SerializeReferrers(&referral_list); |
| 382 EXPECT_EQ(1U, referral_list.GetSize()); | 382 EXPECT_EQ(1U, referral_list.GetSize()); |
| 383 | 383 |
| 384 GURL host_1("http://test_1"); | 384 GURL host_1("http://test_1"); |
| 385 GURL host_2("http://test_2"); | 385 GURL host_2("http://test_2"); |
| 386 predictor.LearnFromNavigation(host_1, host_2); | 386 predictor.LearnFromNavigation(host_1, host_2); |
| 387 | 387 |
| 388 referral_list.Clear(); |
| 388 predictor.SerializeReferrers(&referral_list); | 389 predictor.SerializeReferrers(&referral_list); |
| 389 EXPECT_EQ(2U, referral_list.GetSize()); | 390 EXPECT_EQ(2U, referral_list.GetSize()); |
| 390 | 391 |
| 391 predictor.DiscardAllResults(); | 392 predictor.DiscardAllResults(); |
| 393 referral_list.Clear(); |
| 392 predictor.SerializeReferrers(&referral_list); | 394 predictor.SerializeReferrers(&referral_list); |
| 393 EXPECT_EQ(1U, referral_list.GetSize()); | 395 EXPECT_EQ(1U, referral_list.GetSize()); |
| 394 | 396 |
| 395 predictor.Shutdown(); | 397 predictor.Shutdown(); |
| 396 } | 398 } |
| 397 | 399 |
| 398 class TestPredictorObserver : public PredictorObserver { | 400 class TestPredictorObserver : public PredictorObserver { |
| 399 public: | 401 public: |
| 400 // PredictorObserver implementation: | 402 // PredictorObserver implementation: |
| 401 void OnPreconnectUrl(const GURL& url, | 403 void OnPreconnectUrl(const GURL& url, |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 testing_master.Resolve(goog, UrlInfo::OMNIBOX_MOTIVATED); | 559 testing_master.Resolve(goog, UrlInfo::OMNIBOX_MOTIVATED); |
| 558 | 560 |
| 559 // Proxy may not be in use (the PAC script has not yet been evaluated), so the | 561 // Proxy may not be in use (the PAC script has not yet been evaluated), so the |
| 560 // name has been registered for pre-resolve. | 562 // name has been registered for pre-resolve. |
| 561 EXPECT_FALSE(testing_master.work_queue_.IsEmpty()); | 563 EXPECT_FALSE(testing_master.work_queue_.IsEmpty()); |
| 562 | 564 |
| 563 testing_master.Shutdown(); | 565 testing_master.Shutdown(); |
| 564 } | 566 } |
| 565 | 567 |
| 566 } // namespace chrome_browser_net | 568 } // namespace chrome_browser_net |
| OLD | NEW |