OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <string> | 5 #include <string> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 }; | 104 }; |
105 | 105 |
106 } // namespace | 106 } // namespace |
107 | 107 |
108 TEST(SessionCommandsTest, QuitFails) { | 108 TEST(SessionCommandsTest, QuitFails) { |
109 Session session("id", scoped_ptr<Chrome>(new FailsToQuitChrome())); | 109 Session session("id", scoped_ptr<Chrome>(new FailsToQuitChrome())); |
110 base::DictionaryValue params; | 110 base::DictionaryValue params; |
111 scoped_ptr<base::Value> value; | 111 scoped_ptr<base::Value> value; |
112 ASSERT_EQ(kUnknownError, ExecuteQuit(false, &session, params, &value).code()); | 112 ASSERT_EQ(kUnknownError, ExecuteQuit(false, &session, params, &value).code()); |
113 } | 113 } |
| 114 |
| 115 TEST(SessionCommandsTest, AutoReporting) { |
| 116 DetachChrome* chrome = new DetachChrome(); |
| 117 Session session("id", scoped_ptr<Chrome>(chrome)); |
| 118 base::DictionaryValue params; |
| 119 scoped_ptr<base::Value> value; |
| 120 StatusCode status_code; |
| 121 bool enabled; |
| 122 |
| 123 // autoreporting should be disabled by default |
| 124 status_code = ExecuteIsAutoReporting(&session, params, &value).code(); |
| 125 ASSERT_EQ(kOk, status_code); |
| 126 ASSERT_FALSE(session.auto_reporting_enabled); |
| 127 ASSERT_TRUE(value.get()->GetAsBoolean(&enabled)); |
| 128 ASSERT_FALSE(enabled); |
| 129 |
| 130 // an error should be given if the |enabled| parameter is not set |
| 131 status_code = ExecuteSetAutoReporting(&session, params, &value).code(); |
| 132 ASSERT_EQ(kUnknownError, status_code); |
| 133 |
| 134 // try to enable autoreporting |
| 135 params.SetBoolean("enabled", true); |
| 136 status_code = ExecuteSetAutoReporting(&session, params, &value).code(); |
| 137 ASSERT_EQ(kOk, status_code); |
| 138 ASSERT_TRUE(session.auto_reporting_enabled); |
| 139 |
| 140 // check that autoreporting was enabled successfully |
| 141 status_code = ExecuteIsAutoReporting(&session, params, &value).code(); |
| 142 ASSERT_EQ(kOk, status_code); |
| 143 ASSERT_TRUE(value.get()->GetAsBoolean(&enabled)); |
| 144 ASSERT_TRUE(enabled); |
| 145 |
| 146 // try to disable autoreporting |
| 147 params.SetBoolean("enabled", false); |
| 148 status_code = ExecuteSetAutoReporting(&session, params, &value).code(); |
| 149 ASSERT_EQ(kOk, status_code); |
| 150 ASSERT_FALSE(session.auto_reporting_enabled); |
| 151 |
| 152 // check that autoreporting was disabled successfully |
| 153 status_code = ExecuteIsAutoReporting(&session, params, &value).code(); |
| 154 ASSERT_EQ(kOk, status_code); |
| 155 ASSERT_TRUE(value.get()->GetAsBoolean(&enabled)); |
| 156 ASSERT_FALSE(enabled); |
| 157 } |
OLD | NEW |