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

Unified Diff: base/debug/trace_event_unittest.cc

Issue 12302036: Add a mode flag to the tracing framework. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Spelling fix in content/public/browser. Created 7 years, 10 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: base/debug/trace_event_unittest.cc
diff --git a/base/debug/trace_event_unittest.cc b/base/debug/trace_event_unittest.cc
index 15e11a70f4829a10ded2606e6f52d1fe1e5e0e92..c3020094a56cb2233b6d7fd48a0a1d87a2acae8b 100644
--- a/base/debug/trace_event_unittest.cc
+++ b/base/debug/trace_event_unittest.cc
@@ -73,7 +73,7 @@ class TraceEventTestFixture : public testing::Test {
void BeginTrace() {
event_watch_notification_ = 0;
- TraceLog::GetInstance()->SetEnabled("*");
+ TraceLog::GetInstance()->SetEnabled("*", TraceLog::RECORD_UNTIL_FULL);
}
void EndTraceAndFlush() {
@@ -714,7 +714,7 @@ void HighResSleepForTraceTest(base::TimeDelta elapsed) {
// Simple Test for emitting data and validating it was received.
TEST_F(TraceEventTestFixture, DataCaptured) {
ManualTestSetUp();
- TraceLog::GetInstance()->SetEnabled(true);
+ TraceLog::GetInstance()->SetEnabled(true, TraceLog::RECORD_UNTIL_FULL);
TraceWithAllMacroVariants(NULL);
@@ -738,18 +738,18 @@ TEST_F(TraceEventTestFixture, EnabledObserverFiresOnEnable) {
EXPECT_CALL(observer, OnTraceLogWillEnable())
.Times(1);
- TraceLog::GetInstance()->SetEnabled(true);
+ TraceLog::GetInstance()->SetEnabled(true, TraceLog::RECORD_UNTIL_FULL);
testing::Mock::VerifyAndClear(&observer);
// Cleanup.
TraceLog::GetInstance()->RemoveEnabledStateObserver(&observer);
- TraceLog::GetInstance()->SetEnabled(false);
+ TraceLog::GetInstance()->SetEnabled(false, TraceLog::RECORD_UNTIL_FULL);
}
TEST_F(TraceEventTestFixture, EnabledObserverDoesntFireOnSecondEnable) {
ManualTestSetUp();
- TraceLog::GetInstance()->SetEnabled(true);
+ TraceLog::GetInstance()->SetEnabled(true, TraceLog::RECORD_UNTIL_FULL);
testing::StrictMock<MockEnabledStateChangedObserver> observer;
TraceLog::GetInstance()->AddEnabledStateObserver(&observer);
@@ -758,20 +758,20 @@ TEST_F(TraceEventTestFixture, EnabledObserverDoesntFireOnSecondEnable) {
.Times(0);
EXPECT_CALL(observer, OnTraceLogWillDisable())
.Times(0);
- TraceLog::GetInstance()->SetEnabled(true);
+ TraceLog::GetInstance()->SetEnabled(true, TraceLog::RECORD_UNTIL_FULL);
testing::Mock::VerifyAndClear(&observer);
// Cleanup.
TraceLog::GetInstance()->RemoveEnabledStateObserver(&observer);
- TraceLog::GetInstance()->SetEnabled(false);
- TraceLog::GetInstance()->SetEnabled(false);
+ TraceLog::GetInstance()->SetEnabled(false, TraceLog::RECORD_UNTIL_FULL);
+ TraceLog::GetInstance()->SetEnabled(false, TraceLog::RECORD_UNTIL_FULL);
}
TEST_F(TraceEventTestFixture, EnabledObserverDoesntFireOnNestedDisable) {
ManualTestSetUp();
- TraceLog::GetInstance()->SetEnabled(true);
- TraceLog::GetInstance()->SetEnabled(true);
+ TraceLog::GetInstance()->SetEnabled(true, TraceLog::RECORD_UNTIL_FULL);
+ TraceLog::GetInstance()->SetEnabled(true, TraceLog::RECORD_UNTIL_FULL);
testing::StrictMock<MockEnabledStateChangedObserver> observer;
TraceLog::GetInstance()->AddEnabledStateObserver(&observer);
@@ -780,25 +780,25 @@ TEST_F(TraceEventTestFixture, EnabledObserverDoesntFireOnNestedDisable) {
.Times(0);
EXPECT_CALL(observer, OnTraceLogWillDisable())
.Times(0);
- TraceLog::GetInstance()->SetEnabled(false);
+ TraceLog::GetInstance()->SetEnabled(false, TraceLog::RECORD_UNTIL_FULL);
testing::Mock::VerifyAndClear(&observer);
// Cleanup.
TraceLog::GetInstance()->RemoveEnabledStateObserver(&observer);
- TraceLog::GetInstance()->SetEnabled(false);
+ TraceLog::GetInstance()->SetEnabled(false, TraceLog::RECORD_UNTIL_FULL);
}
TEST_F(TraceEventTestFixture, EnabledObserverFiresOnDisable) {
ManualTestSetUp();
- TraceLog::GetInstance()->SetEnabled(true);
+ TraceLog::GetInstance()->SetEnabled(true, TraceLog::RECORD_UNTIL_FULL);
MockEnabledStateChangedObserver observer;
TraceLog::GetInstance()->AddEnabledStateObserver(&observer);
EXPECT_CALL(observer, OnTraceLogWillDisable())
.Times(1);
- TraceLog::GetInstance()->SetEnabled(false);
+ TraceLog::GetInstance()->SetEnabled(false, TraceLog::RECORD_UNTIL_FULL);
testing::Mock::VerifyAndClear(&observer);
// Cleanup.
@@ -834,7 +834,8 @@ TEST_F(TraceEventTestFixture, Categories) {
Clear();
included_categories.clear();
included_categories.push_back("not_found823564786");
- TraceLog::GetInstance()->SetEnabled(included_categories, empty_categories);
+ TraceLog::GetInstance()->SetEnabled(included_categories, empty_categories,
+ TraceLog::RECORD_UNTIL_FULL);
TRACE_EVENT_INSTANT0("cat1", "name");
TRACE_EVENT_INSTANT0("cat2", "name");
EndTraceAndFlush();
@@ -844,7 +845,8 @@ TEST_F(TraceEventTestFixture, Categories) {
Clear();
included_categories.clear();
included_categories.push_back("inc");
- TraceLog::GetInstance()->SetEnabled(included_categories, empty_categories);
+ TraceLog::GetInstance()->SetEnabled(included_categories, empty_categories,
+ TraceLog::RECORD_UNTIL_FULL);
TRACE_EVENT_INSTANT0("inc", "name");
TRACE_EVENT_INSTANT0("inc2", "name");
EndTraceAndFlush();
@@ -856,7 +858,8 @@ TEST_F(TraceEventTestFixture, Categories) {
included_categories.clear();
included_categories.push_back("inc_wildcard_*");
included_categories.push_back("inc_wildchar_?_end");
- TraceLog::GetInstance()->SetEnabled(included_categories, empty_categories);
+ TraceLog::GetInstance()->SetEnabled(included_categories, empty_categories,
+ TraceLog::RECORD_UNTIL_FULL);
TRACE_EVENT_INSTANT0("inc_wildcard_abc", "included");
TRACE_EVENT_INSTANT0("inc_wildcard_", "included");
TRACE_EVENT_INSTANT0("inc_wildchar_x_end", "included");
@@ -875,7 +878,8 @@ TEST_F(TraceEventTestFixture, Categories) {
Clear();
excluded_categories.clear();
excluded_categories.push_back("not_found823564786");
- TraceLog::GetInstance()->SetEnabled(empty_categories, excluded_categories);
+ TraceLog::GetInstance()->SetEnabled(empty_categories, excluded_categories,
+ TraceLog::RECORD_UNTIL_FULL);
TRACE_EVENT_INSTANT0("cat1", "name");
TRACE_EVENT_INSTANT0("cat2", "name");
EndTraceAndFlush();
@@ -886,7 +890,8 @@ TEST_F(TraceEventTestFixture, Categories) {
Clear();
excluded_categories.clear();
excluded_categories.push_back("inc");
- TraceLog::GetInstance()->SetEnabled(empty_categories, excluded_categories);
+ TraceLog::GetInstance()->SetEnabled(empty_categories, excluded_categories,
+ TraceLog::RECORD_UNTIL_FULL);
TRACE_EVENT_INSTANT0("inc", "name");
TRACE_EVENT_INSTANT0("inc2", "name");
EndTraceAndFlush();
@@ -898,7 +903,8 @@ TEST_F(TraceEventTestFixture, Categories) {
excluded_categories.clear();
excluded_categories.push_back("inc_wildcard_*");
excluded_categories.push_back("inc_wildchar_?_end");
- TraceLog::GetInstance()->SetEnabled(empty_categories, excluded_categories);
+ TraceLog::GetInstance()->SetEnabled(empty_categories, excluded_categories,
+ TraceLog::RECORD_UNTIL_FULL);
TRACE_EVENT_INSTANT0("inc_wildcard_abc", "not_inc");
TRACE_EVENT_INSTANT0("inc_wildcard_", "not_inc");
TRACE_EVENT_INSTANT0("inc_wildchar_x_end", "not_inc");
@@ -1431,17 +1437,17 @@ TEST_F(TraceEventTestFixture, TraceEnableDisable) {
ManualTestSetUp();
TraceLog* trace_log = TraceLog::GetInstance();
- trace_log->SetEnabled(std::string());
+ trace_log->SetEnabled(std::string(), TraceLog::RECORD_UNTIL_FULL);
EXPECT_TRUE(trace_log->IsEnabled());
trace_log->SetDisabled();
EXPECT_FALSE(trace_log->IsEnabled());
- trace_log->SetEnabled(true);
+ trace_log->SetEnabled(true, TraceLog::RECORD_UNTIL_FULL);
EXPECT_TRUE(trace_log->IsEnabled());
const std::vector<std::string> empty;
- trace_log->SetEnabled(empty, empty);
+ trace_log->SetEnabled(empty, empty, TraceLog::RECORD_UNTIL_FULL);
EXPECT_TRUE(trace_log->IsEnabled());
- trace_log->SetEnabled(false);
+ trace_log->SetEnabled(false, TraceLog::RECORD_UNTIL_FULL);
EXPECT_TRUE(trace_log->IsEnabled());
trace_log->SetDisabled();
EXPECT_FALSE(trace_log->IsEnabled());
@@ -1451,14 +1457,14 @@ TEST_F(TraceEventTestFixture, TraceCategoriesAfterNestedEnable) {
ManualTestSetUp();
TraceLog* trace_log = TraceLog::GetInstance();
- trace_log->SetEnabled(std::string("foo,bar"));
+ trace_log->SetEnabled(std::string("foo,bar"), TraceLog::RECORD_UNTIL_FULL);
EXPECT_TRUE(*trace_log->GetCategoryEnabled("foo"));
EXPECT_TRUE(*trace_log->GetCategoryEnabled("bar"));
EXPECT_FALSE(*trace_log->GetCategoryEnabled("baz"));
- trace_log->SetEnabled(std::string("foo2"));
+ trace_log->SetEnabled(std::string("foo2"), TraceLog::RECORD_UNTIL_FULL);
EXPECT_TRUE(*trace_log->GetCategoryEnabled("foo2"));
EXPECT_FALSE(*trace_log->GetCategoryEnabled("baz"));
- trace_log->SetEnabled(std::string(""));
+ trace_log->SetEnabled(std::string(""), TraceLog::RECORD_UNTIL_FULL);
EXPECT_TRUE(*trace_log->GetCategoryEnabled("foo"));
EXPECT_TRUE(*trace_log->GetCategoryEnabled("baz"));
trace_log->SetDisabled();
@@ -1467,10 +1473,10 @@ TEST_F(TraceEventTestFixture, TraceCategoriesAfterNestedEnable) {
EXPECT_FALSE(*trace_log->GetCategoryEnabled("foo"));
EXPECT_FALSE(*trace_log->GetCategoryEnabled("baz"));
- trace_log->SetEnabled(std::string("-foo,-bar"));
+ trace_log->SetEnabled(std::string("-foo,-bar"), TraceLog::RECORD_UNTIL_FULL);
EXPECT_FALSE(*trace_log->GetCategoryEnabled("foo"));
EXPECT_TRUE(*trace_log->GetCategoryEnabled("baz"));
- trace_log->SetEnabled(std::string("moo"));
+ trace_log->SetEnabled(std::string("moo"), TraceLog::RECORD_UNTIL_FULL);
EXPECT_TRUE(*trace_log->GetCategoryEnabled("baz"));
EXPECT_TRUE(*trace_log->GetCategoryEnabled("moo"));
EXPECT_TRUE(*trace_log->GetCategoryEnabled("foo"));
@@ -1478,5 +1484,17 @@ TEST_F(TraceEventTestFixture, TraceCategoriesAfterNestedEnable) {
trace_log->SetDisabled();
}
+TEST_F(TraceEventTestFixture, TraceOptionsParsing) {
+ ManualTestSetUp();
+
+ EXPECT_EQ(TraceLog::RECORD_UNTIL_FULL, TraceLog::TraceOptionsFromString(""));
+
+ EXPECT_EQ(TraceLog::RECORD_UNTIL_FULL,
+ TraceLog::TraceOptionsFromString("blah,something"));
+
+ EXPECT_EQ(TraceLog::RECORD_UNTIL_FULL,
+ TraceLog::TraceOptionsFromString("record-until-full"));
+}
+
} // namespace debug
} // namespace base

Powered by Google App Engine
This is Rietveld 408576698