Index: chrome/test/chromedriver/session_commands_unittest.cc |
diff --git a/chrome/test/chromedriver/session_commands_unittest.cc b/chrome/test/chromedriver/session_commands_unittest.cc |
index e1a2a3682d5ac506a4b1d2052316553a17dc4764..e33439b9f18bbcd65edbc60625be878d424da00d 100644 |
--- a/chrome/test/chromedriver/session_commands_unittest.cc |
+++ b/chrome/test/chromedriver/session_commands_unittest.cc |
@@ -111,3 +111,47 @@ TEST(SessionCommandsTest, QuitFails) { |
scoped_ptr<base::Value> value; |
ASSERT_EQ(kUnknownError, ExecuteQuit(false, &session, params, &value).code()); |
} |
+ |
+TEST(SessionCommandsTest, AutoReporting) { |
+ DetachChrome* chrome = new DetachChrome(); |
+ Session session("id", scoped_ptr<Chrome>(chrome)); |
+ base::DictionaryValue params; |
+ scoped_ptr<base::Value> value; |
+ StatusCode status_code; |
+ bool enabled; |
+ |
+ // autoreporting should be disabled by default |
+ status_code = ExecuteIsAutoReporting(&session, params, &value).code(); |
+ ASSERT_EQ(kOk, status_code); |
+ ASSERT_FALSE(session.auto_reporting_enabled); |
+ ASSERT_TRUE(value.get()->GetAsBoolean(&enabled)); |
+ ASSERT_FALSE(enabled); |
+ |
+ // an error should be given if the |enabled| parameter is not set |
+ status_code = ExecuteSetAutoReporting(&session, params, &value).code(); |
+ ASSERT_EQ(kUnknownError, status_code); |
+ |
+ // try to enable autoreporting |
+ params.SetBoolean("enabled", true); |
+ status_code = ExecuteSetAutoReporting(&session, params, &value).code(); |
+ ASSERT_EQ(kOk, status_code); |
+ ASSERT_TRUE(session.auto_reporting_enabled); |
+ |
+ // check that autoreporting was enabled successfully |
+ status_code = ExecuteIsAutoReporting(&session, params, &value).code(); |
+ ASSERT_EQ(kOk, status_code); |
+ ASSERT_TRUE(value.get()->GetAsBoolean(&enabled)); |
+ ASSERT_TRUE(enabled); |
+ |
+ // try to disable autoreporting |
+ params.SetBoolean("enabled", false); |
+ status_code = ExecuteSetAutoReporting(&session, params, &value).code(); |
+ ASSERT_EQ(kOk, status_code); |
+ ASSERT_FALSE(session.auto_reporting_enabled); |
+ |
+ // check that autoreporting was disabled successfully |
+ status_code = ExecuteIsAutoReporting(&session, params, &value).code(); |
+ ASSERT_EQ(kOk, status_code); |
+ ASSERT_TRUE(value.get()->GetAsBoolean(&enabled)); |
+ ASSERT_FALSE(enabled); |
+} |