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

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

Issue 10843010: Adds a method to the Performance Monitor Database to fetch the most recent metric. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: using the ContainsKey() method Created 8 years, 5 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/database.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/database_unittest.cc
diff --git a/chrome/browser/performance_monitor/database_unittest.cc b/chrome/browser/performance_monitor/database_unittest.cc
index d6661fa02cdc3eeadcf94af22f907bc539598311..355c9ff6c3a7c326f76a6d355fc6e7cd99a43b92 100644
--- a/chrome/browser/performance_monitor/database_unittest.cc
+++ b/chrome/browser/performance_monitor/database_unittest.cc
@@ -285,6 +285,23 @@ TEST_F(PerformanceMonitorDatabaseMetricTest, GetActiveMetrics) {
EXPECT_EQ(expected_metrics, active_metrics);
}
+TEST_F(PerformanceMonitorDatabaseMetricTest, GetRecentMetric) {
+ MetricInfo stat;
+ ASSERT_TRUE(db_->GetRecentStatsForActivityAndMetric(activity_,
+ METRIC_PRIVATE_MEMORY_USAGE, &stat));
+ EXPECT_EQ(3000000, stat.value);
+
+ ASSERT_TRUE(db_->GetRecentStatsForActivityAndMetric(METRIC_CPU_USAGE, &stat));
+ EXPECT_EQ(50.5, stat.value);
+
+ ScopedTempDir dir;
+ CHECK(dir.CreateUniqueTempDir());
+ scoped_ptr<Database> db = Database::Create(dir.path());
+ CHECK(db.get());
+ db->set_clock(scoped_ptr<Database::Clock>(new TestingClock()));
+ EXPECT_FALSE(db->GetRecentStatsForActivityAndMetric(METRIC_CPU_USAGE, &stat));
+}
+
TEST_F(PerformanceMonitorDatabaseMetricTest, GetState) {
std::string key("version");
std::string value("1.0.0.0.1");
« no previous file with comments | « chrome/browser/performance_monitor/database.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698