OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/test/chromedriver/chrome/status.h" | 9 #include "chrome/test/chromedriver/chrome/status.h" |
10 #include "chrome/test/chromedriver/command_listener_proxy.h" | 10 #include "chrome/test/chromedriver/command_listener_proxy.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
12 | 12 |
13 namespace { | 13 namespace { |
14 | 14 |
15 class MockCommandListener : public CommandListener { | 15 class MockCommandListener : public CommandListener { |
16 public: | 16 public: |
17 MockCommandListener() : called_(false) {} | 17 MockCommandListener() : called_(false) {} |
18 virtual ~MockCommandListener() {} | 18 virtual ~MockCommandListener() {} |
19 | 19 |
20 virtual Status BeforeCommand(const std::string& command_name) OVERRIDE { | 20 virtual Status BeforeCommand(const std::string& command_name) override { |
21 called_ = true; | 21 called_ = true; |
22 EXPECT_STREQ("cmd", command_name.c_str()); | 22 EXPECT_STREQ("cmd", command_name.c_str()); |
23 return Status(kOk); | 23 return Status(kOk); |
24 } | 24 } |
25 | 25 |
26 void VerifyCalled() { | 26 void VerifyCalled() { |
27 EXPECT_TRUE(called_); | 27 EXPECT_TRUE(called_); |
28 } | 28 } |
29 | 29 |
30 void VerifyNotCalled() { | 30 void VerifyNotCalled() { |
31 EXPECT_FALSE(called_); | 31 EXPECT_FALSE(called_); |
32 } | 32 } |
33 | 33 |
34 private: | 34 private: |
35 bool called_; | 35 bool called_; |
36 }; | 36 }; |
37 | 37 |
38 } // namespace | 38 } // namespace |
39 | 39 |
40 TEST(CommandListenerProxy, ForwardsCommands) { | 40 TEST(CommandListenerProxy, ForwardsCommands) { |
41 MockCommandListener listener; | 41 MockCommandListener listener; |
42 listener.VerifyNotCalled(); | 42 listener.VerifyNotCalled(); |
43 CommandListenerProxy proxy(&listener); | 43 CommandListenerProxy proxy(&listener); |
44 listener.VerifyNotCalled(); | 44 listener.VerifyNotCalled(); |
45 ASSERT_EQ(kOk, proxy.BeforeCommand("cmd").code()); | 45 ASSERT_EQ(kOk, proxy.BeforeCommand("cmd").code()); |
46 listener.VerifyCalled(); | 46 listener.VerifyCalled(); |
47 } | 47 } |
OLD | NEW |