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/run_loop.h" |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 test_host_data_.insert(std::make_pair("www.yahoo.com", yahoo)); | 423 test_host_data_.insert(std::make_pair("www.yahoo.com", yahoo)); |
424 | 424 |
425 PrefetchData empty_url_data(PREFETCH_KEY_TYPE_URL, std::string()); | 425 PrefetchData empty_url_data(PREFETCH_KEY_TYPE_URL, std::string()); |
426 tables_->UpdateData(empty_url_data, facebook); | 426 tables_->UpdateData(empty_url_data, facebook); |
427 tables_->UpdateData(empty_url_data, yahoo); | 427 tables_->UpdateData(empty_url_data, yahoo); |
428 } | 428 } |
429 } | 429 } |
430 | 430 |
431 // Test cases. | 431 // Test cases. |
432 | 432 |
| 433 TEST_F(ResourcePrefetchPredictorTablesTest, ComputeScore) { |
| 434 typedef ResourcePrefetchPredictorTables::ResourceRow ResourceRow; |
| 435 ResourceRow js_resource(std::string(), |
| 436 "http://www.resources.google.com/script.js", |
| 437 content::RESOURCE_TYPE_SCRIPT, 11, 0, 0, 1.); |
| 438 ResourceRow image_resource(std::string(), |
| 439 "http://www.resources.google.com/image.jpg", |
| 440 content::RESOURCE_TYPE_IMAGE, 11, 0, 0, 1.); |
| 441 ResourceRow css_resource(std::string(), |
| 442 "http://www.resources.google.com/stylesheet.css", |
| 443 content::RESOURCE_TYPE_STYLESHEET, 11, 0, 0, 1.); |
| 444 ResourceRow font_resource(std::string(), |
| 445 "http://www.resources.google.com/font.woff", |
| 446 content::RESOURCE_TYPE_FONT_RESOURCE, 11, 0, 0, 1.); |
| 447 EXPECT_TRUE(js_resource.score == css_resource.score); |
| 448 EXPECT_TRUE(js_resource.score == font_resource.score); |
| 449 EXPECT_NEAR(199., js_resource.score, 1e-4); |
| 450 EXPECT_NEAR(99., image_resource.score, 1e-4); |
| 451 } |
| 452 |
433 TEST_F(ResourcePrefetchPredictorTablesTest, GetAllData) { | 453 TEST_F(ResourcePrefetchPredictorTablesTest, GetAllData) { |
434 TestGetAllData(); | 454 TestGetAllData(); |
435 } | 455 } |
436 | 456 |
437 TEST_F(ResourcePrefetchPredictorTablesTest, UpdateData) { | 457 TEST_F(ResourcePrefetchPredictorTablesTest, UpdateData) { |
438 TestUpdateData(); | 458 TestUpdateData(); |
439 } | 459 } |
440 | 460 |
441 TEST_F(ResourcePrefetchPredictorTablesTest, DeleteData) { | 461 TEST_F(ResourcePrefetchPredictorTablesTest, DeleteData) { |
442 TestDeleteData(); | 462 TestDeleteData(); |
(...skipping 21 matching lines...) Expand all Loading... |
464 | 484 |
465 TEST_F(ResourcePrefetchPredictorTablesReopenTest, DeleteSingleDataPoint) { | 485 TEST_F(ResourcePrefetchPredictorTablesReopenTest, DeleteSingleDataPoint) { |
466 TestDeleteSingleDataPoint(); | 486 TestDeleteSingleDataPoint(); |
467 } | 487 } |
468 | 488 |
469 TEST_F(ResourcePrefetchPredictorTablesReopenTest, DeleteAllData) { | 489 TEST_F(ResourcePrefetchPredictorTablesReopenTest, DeleteAllData) { |
470 TestDeleteAllData(); | 490 TestDeleteAllData(); |
471 } | 491 } |
472 | 492 |
473 } // namespace predictors | 493 } // namespace predictors |
OLD | NEW |