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

Unified Diff: chrome/browser/performance_monitor/performance_monitor_browsertest.cc

Issue 10829342: Add BytesRead metric to CPM (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698