Chromium Code Reviews| Index: chrome/test/chromedriver/devtools_state_unittest.cc |
| diff --git a/chrome/test/chromedriver/devtools_state_unittest.cc b/chrome/test/chromedriver/devtools_state_unittest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..4534045daf046f54dbf165aaff6bb6f5659b51e5 |
| --- /dev/null |
| +++ b/chrome/test/chromedriver/devtools_state_unittest.cc |
| @@ -0,0 +1,66 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include <list> |
| +#include <string> |
| + |
| +#include "base/compiler_specific.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/values.h" |
| +#include "chrome/test/chromedriver/devtools_client.h" |
| +#include "chrome/test/chromedriver/devtools_state.h" |
| +#include "chrome/test/chromedriver/status.h" |
| +#include "testing/gtest/include/gtest/gtest.h" |
| + |
| +namespace { |
| + |
| +class FakeDevToolsClient : public DevToolsClient { |
| + public: |
| + FakeDevToolsClient() : send_count_(0) {} |
| + virtual ~FakeDevToolsClient() {} |
| + |
| + int GetSendCount() { |
| + return send_count_; |
| + } |
| + |
| + // Overridden from DevToolsClient: |
| + virtual Status SendCommand(const std::string& method, |
| + const base::DictionaryValue& params) OVERRIDE { |
| + ++send_count_; |
| + return Status(kOk); |
| + } |
| + virtual Status SendCommandAndGetResult( |
| + const std::string& method, |
| + const base::DictionaryValue& params, |
| + scoped_ptr<base::DictionaryValue>* result) OVERRIDE { |
| + ++send_count_; |
| + return Status(kOk); |
| + } |
| + virtual void AddListener(DevToolsEventListener* listener) OVERRIDE {} |
| + virtual Status HandleEventsUntil( |
| + const ConditionalFunc& conditional_func) OVERRIDE { |
| + return Status(kOk); |
| + } |
| + |
| + private: |
|
kkania
2013/01/30 18:50:29
bad indent
craigdh
2013/01/30 22:20:04
Done.
|
| + int send_count_; |
| +}; |
| + |
| +} // namespace |
| + |
| +TEST(DevToolsState, Init) { |
| + FakeDevToolsClient client; |
| + DevToolsState state(&client); |
| + base::DictionaryValue params; |
| + state.Init(); |
| + ASSERT_EQ(client.GetSendCount(), 3); |
|
kkania
2013/01/30 18:50:29
this is brittle and I'm not sure is very helpful.
craigdh
2013/01/30 22:20:04
Done.
|
| +} |
| + |
| +TEST(DevToolsState, OnEvent) { |
| + FakeDevToolsClient client; |
| + DevToolsState state(&client); |
| + base::DictionaryValue params; |
| + state.OnEvent("DOM.documentUpdated", params); |
| + ASSERT_EQ(client.GetSendCount(), 1); |
| +} |