Index: chrome/browser/performance_monitor/performance_monitor_browsertest.cc |
diff --git a/chrome/browser/performance_monitor/performance_monitor_browsertest.cc b/chrome/browser/performance_monitor/performance_monitor_browsertest.cc |
index 3d0234cefc8b4a2a30da6a4eeef673fdc17a1c35..663186db90f93d09cd680d7cfe16ae1a94dbe6a1 100644 |
--- a/chrome/browser/performance_monitor/performance_monitor_browsertest.cc |
+++ b/chrome/browser/performance_monitor/performance_monitor_browsertest.cc |
@@ -159,6 +159,10 @@ class PerformanceMonitorBrowserTest : public ExtensionBrowserTest { |
performance_monitor_->Start(); |
windowed_observer.Wait(); |
+ |
+ // We stop the timer in charge of doing timed collections so that we can |
+ // enforce when, and how many times, we do these collections. |
+ performance_monitor_->timer_.Stop(); |
} |
// A handle for gathering statistics from the database, which must be done on |
@@ -721,4 +725,36 @@ IN_PROC_BROWSER_TEST_F(PerformanceMonitorBrowserTest, PageLoadTime) { |
ASSERT_LT(metrics[1].value, kMaxLoadTime.ToInternalValue()); |
} |
+IN_PROC_BROWSER_TEST_F(PerformanceMonitorBrowserTest, BytesRead) { |
+ FilePath test_dir; |
+ PathService::Get(chrome::DIR_TEST_DATA, &test_dir); |
+ |
+ int64 page1_size = 0; |
+ file_util::GetFileSize(test_dir.AppendASCII("title1.html"), &page1_size); |
+ |
+ int64 page2_size = 0; |
+ file_util::GetFileSize(test_dir.AppendASCII("title2.html"), &page2_size); |
+ |
+ ui_test_utils::NavigateToURL( |
+ browser(), |
+ ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), |
+ FilePath(FILE_PATH_LITERAL("title1.html")))); |
+ performance_monitor()->DoTimedCollections(); |
+ |
+ Database::MetricInfoVector metrics = GetStats(METRIC_BYTES_READ); |
+ ASSERT_EQ(1u, metrics.size()); |
+ ASSERT_EQ(page1_size, metrics[0].value); |
+ |
+ ui_test_utils::NavigateToURL( |
+ browser(), |
+ ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), |
+ FilePath(FILE_PATH_LITERAL("title2.html")))); |
+ performance_monitor()->DoTimedCollections(); |
+ |
+ metrics = GetStats(METRIC_BYTES_READ); |
+ |
+ ASSERT_EQ(2u, metrics.size()); |
+ ASSERT_EQ(page1_size + page2_size, metrics[1].value); |
+} |
+ |
} // namespace performance_monitor |