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

Unified Diff: trunk/src/chrome/test/chromedriver/commands_unittest.cc

Issue 392623005: Revert 283003 "[ChromeDriver] Subscribe PerformanceLogger to Com..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 5 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
« no previous file with comments | « trunk/src/chrome/test/chromedriver/commands.cc ('k') | trunk/src/chrome/test/chromedriver/logging.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: trunk/src/chrome/test/chromedriver/commands_unittest.cc
===================================================================
--- trunk/src/chrome/test/chromedriver/commands_unittest.cc (revision 283022)
+++ trunk/src/chrome/test/chromedriver/commands_unittest.cc (working copy)
@@ -546,123 +546,3 @@
ExecuteFindChildElements(
1, &session, &web_view, element_id, params, &result).code());
}
-
-namespace {
-
-class MockCommandListener : public CommandListener {
- public:
- MockCommandListener() : called_(false) {}
- virtual ~MockCommandListener() {}
-
- virtual Status BeforeCommand(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_;
-};
-
-Status ExecuteAddListenerToSessionCommand(
- MockCommandListener* listener,
- Session* session,
- const base::DictionaryValue& params,
- scoped_ptr<base::Value>* return_value) {
- session->command_listeners.push_back(listener);
- listener->VerifyNotCalled();
- return Status(kOk);
-}
-
-Status ExecuteQuitSessionCommand(
- Session* session,
- const base::DictionaryValue& params,
- scoped_ptr<base::Value>* return_value) {
- session->quit = true;
- return Status(kOk);
-}
-
-void OnAddListenerToSessionCommand(
- MockCommandListener* listener,
- base::RunLoop* run_loop,
- const Status& status,
- scoped_ptr<base::Value> value,
- const std::string& session_id) {
- ASSERT_EQ(kOk, status.code());
- listener->VerifyNotCalled();
- run_loop->Quit();
-}
-
-void OnQuitSessionCommand(
- MockCommandListener* listener,
- base::RunLoop* run_loop,
- const Status& status,
- scoped_ptr<base::Value> value,
- const std::string& session_id) {
- ASSERT_EQ(kOk, status.code());
- listener->VerifyCalled();
- run_loop->Quit();
-}
-
-} // namespace
-
-TEST(CommandsTest, SessionNotifiedOfCommand) {
- SessionThreadMap map;
- linked_ptr<base::Thread> thread(new base::Thread("1"));
- ASSERT_TRUE(thread->Start());
- std::string id("id");
- thread->message_loop()->PostTask(
- FROM_HERE,
- base::Bind(&internal::CreateSessionOnSessionThreadForTesting, id));
- map[id] = thread;
-
- base::DictionaryValue params;
- // |listener| is owned by and will be destroyed by |session|
- MockCommandListener* listener = new MockCommandListener();
- SessionCommand cmd = base::Bind(
- &ExecuteAddListenerToSessionCommand, listener);
-
- base::MessageLoop loop;
- base::RunLoop run_loop_addlistener;
-
- // |CommandListener|s are notified immediately before commands are run.
- // Here, the command adds |listener| to the session, so |listener|
- // should not be notified since it will not have been added yet.
- ExecuteSessionCommand(
- &map,
- "cmd",
- cmd,
- false,
- params,
- id,
- base::Bind(&OnAddListenerToSessionCommand, listener,
- &run_loop_addlistener));
-
- run_loop_addlistener.Run();
-
- base::RunLoop run_loop_testlistener;
- cmd = base::Bind(
- &ExecuteQuitSessionCommand);
-
- // |listener| was added to |session| by ExecuteAddListenerToSessionCommand
- // and should be notified before the next command, ExecuteQuitSessionCommand.
- ExecuteSessionCommand(
- &map,
- "cmd",
- cmd,
- false,
- params,
- id,
- base::Bind(&OnQuitSessionCommand, listener,
- &run_loop_testlistener));
-
- run_loop_testlistener.Run();
-}
« no previous file with comments | « trunk/src/chrome/test/chromedriver/commands.cc ('k') | trunk/src/chrome/test/chromedriver/logging.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698