| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 base::DictionaryValue params; | 131 base::DictionaryValue params; |
| 132 params.SetInteger("param", 5); | 132 params.SetInteger("param", 5); |
| 133 base::FundamentalValue expected_value(6); | 133 base::FundamentalValue expected_value(6); |
| 134 SessionCommand cmd = base::Bind( | 134 SessionCommand cmd = base::Bind( |
| 135 &ExecuteSimpleCommand, id, ¶ms, &expected_value); | 135 &ExecuteSimpleCommand, id, ¶ms, &expected_value); |
| 136 | 136 |
| 137 base::MessageLoop loop; | 137 base::MessageLoop loop; |
| 138 base::RunLoop run_loop; | 138 base::RunLoop run_loop; |
| 139 ExecuteSessionCommand( | 139 ExecuteSessionCommand( |
| 140 &map, | 140 &map, |
| 141 "cmd", |
| 141 cmd, | 142 cmd, |
| 142 false, | 143 false, |
| 143 params, | 144 params, |
| 144 id, | 145 id, |
| 145 base::Bind(&OnSimpleCommand, &run_loop, id, &expected_value)); | 146 base::Bind(&OnSimpleCommand, &run_loop, id, &expected_value)); |
| 146 run_loop.Run(); | 147 run_loop.Run(); |
| 147 } | 148 } |
| 148 | 149 |
| 149 namespace { | 150 namespace { |
| 150 | 151 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 169 EXPECT_EQ(kOk, status.code()); | 170 EXPECT_EQ(kOk, status.code()); |
| 170 EXPECT_FALSE(value.get()); | 171 EXPECT_FALSE(value.get()); |
| 171 } | 172 } |
| 172 | 173 |
| 173 } // namespace | 174 } // namespace |
| 174 | 175 |
| 175 TEST(CommandsTest, ExecuteSessionCommandOnNoSuchSession) { | 176 TEST(CommandsTest, ExecuteSessionCommandOnNoSuchSession) { |
| 176 SessionThreadMap map; | 177 SessionThreadMap map; |
| 177 base::DictionaryValue params; | 178 base::DictionaryValue params; |
| 178 ExecuteSessionCommand(&map, | 179 ExecuteSessionCommand(&map, |
| 180 "cmd", |
| 179 base::Bind(&ShouldNotBeCalled), | 181 base::Bind(&ShouldNotBeCalled), |
| 180 false, | 182 false, |
| 181 params, | 183 params, |
| 182 "session", | 184 "session", |
| 183 base::Bind(&OnNoSuchSession)); | 185 base::Bind(&OnNoSuchSession)); |
| 184 } | 186 } |
| 185 | 187 |
| 186 TEST(CommandsTest, ExecuteSessionCommandOnNoSuchSessionWhenItExpectsOk) { | 188 TEST(CommandsTest, ExecuteSessionCommandOnNoSuchSessionWhenItExpectsOk) { |
| 187 SessionThreadMap map; | 189 SessionThreadMap map; |
| 188 base::DictionaryValue params; | 190 base::DictionaryValue params; |
| 189 ExecuteSessionCommand(&map, | 191 ExecuteSessionCommand(&map, |
| 192 "cmd", |
| 190 base::Bind(&ShouldNotBeCalled), | 193 base::Bind(&ShouldNotBeCalled), |
| 191 true, | 194 true, |
| 192 params, | 195 params, |
| 193 "session", | 196 "session", |
| 194 base::Bind(&OnNoSuchSessionIsOk)); | 197 base::Bind(&OnNoSuchSessionIsOk)); |
| 195 } | 198 } |
| 196 | 199 |
| 197 namespace { | 200 namespace { |
| 198 | 201 |
| 199 void OnNoSuchSessionAndQuit(base::RunLoop* run_loop, | 202 void OnNoSuchSessionAndQuit(base::RunLoop* run_loop, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 210 TEST(CommandsTest, ExecuteSessionCommandOnJustDeletedSession) { | 213 TEST(CommandsTest, ExecuteSessionCommandOnJustDeletedSession) { |
| 211 SessionThreadMap map; | 214 SessionThreadMap map; |
| 212 linked_ptr<base::Thread> thread(new base::Thread("1")); | 215 linked_ptr<base::Thread> thread(new base::Thread("1")); |
| 213 ASSERT_TRUE(thread->Start()); | 216 ASSERT_TRUE(thread->Start()); |
| 214 std::string id("id"); | 217 std::string id("id"); |
| 215 map[id] = thread; | 218 map[id] = thread; |
| 216 | 219 |
| 217 base::MessageLoop loop; | 220 base::MessageLoop loop; |
| 218 base::RunLoop run_loop; | 221 base::RunLoop run_loop; |
| 219 ExecuteSessionCommand(&map, | 222 ExecuteSessionCommand(&map, |
| 223 "cmd", |
| 220 base::Bind(&ShouldNotBeCalled), | 224 base::Bind(&ShouldNotBeCalled), |
| 221 false, | 225 false, |
| 222 base::DictionaryValue(), | 226 base::DictionaryValue(), |
| 223 "session", | 227 "session", |
| 224 base::Bind(&OnNoSuchSessionAndQuit, &run_loop)); | 228 base::Bind(&OnNoSuchSessionAndQuit, &run_loop)); |
| 225 run_loop.Run(); | 229 run_loop.Run(); |
| 226 } | 230 } |
| 227 | 231 |
| 228 namespace { | 232 namespace { |
| 229 | 233 |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 scoped_ptr<base::Value> result; | 539 scoped_ptr<base::Value> result; |
| 536 ASSERT_EQ( | 540 ASSERT_EQ( |
| 537 kStaleElementReference, | 541 kStaleElementReference, |
| 538 ExecuteFindChildElement( | 542 ExecuteFindChildElement( |
| 539 1, &session, &web_view, element_id, params, &result).code()); | 543 1, &session, &web_view, element_id, params, &result).code()); |
| 540 ASSERT_EQ( | 544 ASSERT_EQ( |
| 541 kStaleElementReference, | 545 kStaleElementReference, |
| 542 ExecuteFindChildElements( | 546 ExecuteFindChildElements( |
| 543 1, &session, &web_view, element_id, params, &result).code()); | 547 1, &session, &web_view, element_id, params, &result).code()); |
| 544 } | 548 } |
| OLD | NEW |