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

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: Removed const char[]s so that FILE_PATH_LITERAL and append both work 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
« no previous file with comments | « chrome/browser/performance_monitor/performance_monitor.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 4ddcbe27749a3c8a402acdf4602ba4c2cfb40391..519e162259ea28dcbd1999cad368fadd62b901d9 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
@@ -712,7 +716,7 @@ IN_PROC_BROWSER_TEST_F(PerformanceMonitorBrowserTest, PageLoadTime) {
ui_test_utils::NavigateToURL(
browser(),
ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory),
- FilePath(FILE_PATH_LITERAL("title2.html"))));
+ FilePath(FILE_PATH_LITERAL("title1.html"))));
Database::MetricVector metrics = GetStats(METRIC_PAGE_LOAD_TIME);
@@ -721,4 +725,46 @@ IN_PROC_BROWSER_TEST_F(PerformanceMonitorBrowserTest, PageLoadTime) {
ASSERT_LT(metrics[1].value, kMaxLoadTime.ToInternalValue());
}
+IN_PROC_BROWSER_TEST_F(PerformanceMonitorBrowserTest, NetworkBytesRead) {
+ FilePath test_dir;
+ PathService::Get(chrome::DIR_TEST_DATA, &test_dir);
+
+ int64 page1_size = 0;
+ ASSERT_TRUE(file_util::GetFileSize(test_dir.AppendASCII("title1.html"),
+ &page1_size));
+
+ int64 page2_size = 0;
+ ASSERT_TRUE(file_util::GetFileSize(test_dir.AppendASCII("title2.html"),
+ &page2_size));
+
+ ASSERT_TRUE(test_server()->Start());
+
+ ui_test_utils::NavigateToURL(
+ browser(),
+ test_server()->GetURL(std::string("files/").append("title1.html")));
+
+ performance_monitor()->DoTimedCollections();
+
+ // Since network bytes are read and set on the IO thread, we must flush this
+ // additional thread to be sure that all messages are run.
+ RunAllPendingInMessageLoop(content::BrowserThread::IO);
+
+ Database::MetricVector metrics = GetStats(METRIC_NETWORK_BYTES_READ);
+ ASSERT_EQ(1u, metrics.size());
+ // Since these pages are read over the "network" (actually the test_server),
+ // some extraneous information is carried along, and the best check we can do
+ // is for greater than or equal to.
+ EXPECT_GE(metrics[0].value, page1_size);
+
+ ui_test_utils::NavigateToURL(
+ browser(),
+ test_server()->GetURL(std::string("files/").append("title2.html")));
+
+ performance_monitor()->DoTimedCollections();
+
+ metrics = GetStats(METRIC_NETWORK_BYTES_READ);
+ ASSERT_EQ(2u, metrics.size());
+ EXPECT_GE(metrics[1].value, page1_size + page2_size);
+}
+
} // namespace performance_monitor
« no previous file with comments | « chrome/browser/performance_monitor/performance_monitor.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698