| 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/threading/sequenced_worker_pool.h" | 10 #include "base/threading/sequenced_worker_pool.h" |
| (...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 751 ASSERT_EQ(2u, metrics.size()); | 751 ASSERT_EQ(2u, metrics.size()); |
| 752 ASSERT_LT(metrics[0].value, kMaxLoadTime.ToInternalValue()); | 752 ASSERT_LT(metrics[0].value, kMaxLoadTime.ToInternalValue()); |
| 753 ASSERT_LT(metrics[1].value, kMaxLoadTime.ToInternalValue()); | 753 ASSERT_LT(metrics[1].value, kMaxLoadTime.ToInternalValue()); |
| 754 } | 754 } |
| 755 | 755 |
| 756 IN_PROC_BROWSER_TEST_F(PerformanceMonitorBrowserTest, NetworkBytesRead) { | 756 IN_PROC_BROWSER_TEST_F(PerformanceMonitorBrowserTest, NetworkBytesRead) { |
| 757 base::FilePath test_dir; | 757 base::FilePath test_dir; |
| 758 PathService::Get(chrome::DIR_TEST_DATA, &test_dir); | 758 PathService::Get(chrome::DIR_TEST_DATA, &test_dir); |
| 759 | 759 |
| 760 int64 page1_size = 0; | 760 int64 page1_size = 0; |
| 761 ASSERT_TRUE(file_util::GetFileSize(test_dir.AppendASCII("title1.html"), | 761 ASSERT_TRUE(base::GetFileSize(test_dir.AppendASCII("title1.html"), |
| 762 &page1_size)); | 762 &page1_size)); |
| 763 | 763 |
| 764 int64 page2_size = 0; | 764 int64 page2_size = 0; |
| 765 ASSERT_TRUE(file_util::GetFileSize(test_dir.AppendASCII("title2.html"), | 765 ASSERT_TRUE(base::GetFileSize(test_dir.AppendASCII("title2.html"), |
| 766 &page2_size)); | 766 &page2_size)); |
| 767 | 767 |
| 768 ASSERT_TRUE(test_server()->Start()); | 768 ASSERT_TRUE(test_server()->Start()); |
| 769 | 769 |
| 770 ui_test_utils::NavigateToURL( | 770 ui_test_utils::NavigateToURL( |
| 771 browser(), | 771 browser(), |
| 772 test_server()->GetURL(std::string("files/").append("title1.html"))); | 772 test_server()->GetURL(std::string("files/").append("title1.html"))); |
| 773 | 773 |
| 774 GatherStatistics(); | 774 GatherStatistics(); |
| 775 | 775 |
| 776 Database::MetricVector metrics = GetStats(METRIC_NETWORK_BYTES_READ); | 776 Database::MetricVector metrics = GetStats(METRIC_NETWORK_BYTES_READ); |
| 777 ASSERT_EQ(1u, metrics.size()); | 777 ASSERT_EQ(1u, metrics.size()); |
| 778 // Since these pages are read over the "network" (actually the test_server), | 778 // Since these pages are read over the "network" (actually the test_server), |
| 779 // some extraneous information is carried along, and the best check we can do | 779 // some extraneous information is carried along, and the best check we can do |
| 780 // is for greater than or equal to. | 780 // is for greater than or equal to. |
| 781 EXPECT_GE(metrics[0].value, page1_size); | 781 EXPECT_GE(metrics[0].value, page1_size); |
| 782 | 782 |
| 783 ui_test_utils::NavigateToURL( | 783 ui_test_utils::NavigateToURL( |
| 784 browser(), | 784 browser(), |
| 785 test_server()->GetURL(std::string("files/").append("title2.html"))); | 785 test_server()->GetURL(std::string("files/").append("title2.html"))); |
| 786 | 786 |
| 787 GatherStatistics(); | 787 GatherStatistics(); |
| 788 | 788 |
| 789 metrics = GetStats(METRIC_NETWORK_BYTES_READ); | 789 metrics = GetStats(METRIC_NETWORK_BYTES_READ); |
| 790 ASSERT_EQ(2u, metrics.size()); | 790 ASSERT_EQ(2u, metrics.size()); |
| 791 EXPECT_GE(metrics[1].value, page1_size + page2_size); | 791 EXPECT_GE(metrics[1].value, page1_size + page2_size); |
| 792 } | 792 } |
| 793 | 793 |
| 794 } // namespace performance_monitor | 794 } // namespace performance_monitor |
| OLD | NEW |