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

Unified Diff: chrome/test/chromedriver/session_unittest.cc

Issue 331943003: [ChromeDriver] Added CommandListener interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 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
« chrome/test/chromedriver/session.h ('K') | « chrome/test/chromedriver/session.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/chromedriver/session_unittest.cc
diff --git a/chrome/test/chromedriver/session_unittest.cc b/chrome/test/chromedriver/session_unittest.cc
index 23fb779bd26a14b3667c4bf6837393e7300eb1dd..6af89d65fe67a27d763cc8a43685c9b98e149879 100644
--- a/chrome/test/chromedriver/session_unittest.cc
+++ b/chrome/test/chromedriver/session_unittest.cc
@@ -32,6 +32,29 @@ class MockChrome : public StubChrome {
StubWebView web_view_;
};
+class MockCommandListener : public CommandListener {
stgao 2014/06/15 23:54:41 Duplicate code as the one in commands_unittest.cc
johnmoore 2014/06/16 17:28:34 Would it make sense for the stub class to perform
+ public:
+ MockCommandListener() : called_(false) {}
+ virtual ~MockCommandListener() {}
+
+ virtual Status OnCommand(const std::string& command_name) OVERRIDE {
+ called_ = true;
+ EXPECT_STREQ("cmd", command_name.c_str());
+ return Status(kOk);
+ }
+
+ void VerifyCalled() {
+ EXPECT_TRUE(called_);
+ }
+
+ void VerifyNotCalled() {
+ EXPECT_FALSE(called_);
+ }
+
+ private:
+ bool called_;
+};
+
} // namespace
TEST(Session, GetTargetWindowNoChrome) {
@@ -101,3 +124,20 @@ TEST(Session, SwitchToTopFrame) {
session.SwitchToTopFrame();
ASSERT_EQ(std::string(), session.GetCurrentFrameId());
}
+
+TEST(Session, OnCommand) {
+ Session session("1");
+ MockCommandListener* listener1 = new MockCommandListener();
stgao 2014/06/15 23:57:38 Memory leak: please use a scoped_ptr.
johnmoore 2014/06/16 20:49:18 session.AddListener should take care of transferri
+ MockCommandListener* listener2 = new MockCommandListener();
+ MockCommandListener* listener3 = new MockCommandListener();
+ session.AddListener(listener1);
+ session.AddListener(listener2);
+ session.AddListener(listener3);
+ listener1->VerifyNotCalled();
+ listener2->VerifyNotCalled();
+ listener3->VerifyNotCalled();
+ session.OnCommand("cmd");
+ listener1->VerifyCalled();
+ listener2->VerifyCalled();
+ listener3->VerifyCalled();
+}
« chrome/test/chromedriver/session.h ('K') | « chrome/test/chromedriver/session.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698