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

Side by Side Diff: chrome/test/chromedriver/commands_unittest.cc

Issue 11415205: [chromedriver] Implement connecting to devtools and loading a page. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 8 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/test/chromedriver/commands.cc ('k') | chrome/test/chromedriver/devtools_client.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/file_path.h" 10 #include "base/file_path.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/synchronization/lock.h" 12 #include "base/synchronization/lock.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "chrome/test/chromedriver/chrome.h" 14 #include "chrome/test/chromedriver/chrome.h"
15 #include "chrome/test/chromedriver/chrome_launcher.h" 15 #include "chrome/test/chromedriver/chrome_launcher.h"
16 #include "chrome/test/chromedriver/command_executor_impl.h" 16 #include "chrome/test/chromedriver/command_executor_impl.h"
17 #include "chrome/test/chromedriver/commands.h" 17 #include "chrome/test/chromedriver/commands.h"
18 #include "chrome/test/chromedriver/fake_session_accessor.h" 18 #include "chrome/test/chromedriver/fake_session_accessor.h"
19 #include "chrome/test/chromedriver/status.h" 19 #include "chrome/test/chromedriver/status.h"
20 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
21 21
22 namespace { 22 namespace {
23 23
24 class StubChrome : public Chrome { 24 class StubChrome : public Chrome {
25 public: 25 public:
26 StubChrome() {} 26 StubChrome() {}
27 virtual ~StubChrome() {} 27 virtual ~StubChrome() {}
28 28
29 // Overridden from Chrome: 29 // Overridden from Chrome:
30 virtual Status Load(const std::string& url) OVERRIDE {
31 return Status(kOk);
32 }
30 virtual Status Quit() OVERRIDE { 33 virtual Status Quit() OVERRIDE {
31 return Status(kOk); 34 return Status(kOk);
32 } 35 }
33 }; 36 };
34 37
35 class OkLauncher : public ChromeLauncher { 38 class OkLauncher : public ChromeLauncher {
36 public: 39 public:
37 OkLauncher() {} 40 OkLauncher() {}
38 virtual ~OkLauncher() {} 41 virtual ~OkLauncher() {}
39 42
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 scoped_refptr<SessionAccessor>(new FakeSessionAccessor(&session))); 148 scoped_refptr<SessionAccessor>(new FakeSessionAccessor(&session)));
146 base::DictionaryValue params; 149 base::DictionaryValue params;
147 scoped_ptr<base::Value> value; 150 scoped_ptr<base::Value> value;
148 ASSERT_EQ(kOk, ExecuteQuit(&map, &session, params, &value).code()); 151 ASSERT_EQ(kOk, ExecuteQuit(&map, &session, params, &value).code());
149 ASSERT_FALSE(map.Has(session.id)); 152 ASSERT_FALSE(map.Has(session.id));
150 ASSERT_FALSE(value.get()); 153 ASSERT_FALSE(value.get());
151 } 154 }
152 155
153 namespace { 156 namespace {
154 157
155 class FailsToQuitChrome : public Chrome { 158 class FailsToQuitChrome : public StubChrome {
156 public: 159 public:
157 FailsToQuitChrome() {} 160 FailsToQuitChrome() {}
158 virtual ~FailsToQuitChrome() {} 161 virtual ~FailsToQuitChrome() {}
159 162
160 // Overridden from Chrome: 163 // Overridden from Chrome:
161 virtual Status Quit() OVERRIDE { 164 virtual Status Quit() OVERRIDE {
162 return Status(kUnknownError); 165 return Status(kUnknownError);
163 } 166 }
164 }; 167 };
165 168
166 } // namespace 169 } // namespace
167 170
168 TEST(CommandsTest, QuitFails) { 171 TEST(CommandsTest, QuitFails) {
169 SessionMap map; 172 SessionMap map;
170 Session session("id", scoped_ptr<Chrome>(new FailsToQuitChrome())); 173 Session session("id", scoped_ptr<Chrome>(new FailsToQuitChrome()));
171 map.Set(session.id, 174 map.Set(session.id,
172 scoped_refptr<SessionAccessor>(new FakeSessionAccessor(&session))); 175 scoped_refptr<SessionAccessor>(new FakeSessionAccessor(&session)));
173 base::DictionaryValue params; 176 base::DictionaryValue params;
174 scoped_ptr<base::Value> value; 177 scoped_ptr<base::Value> value;
175 ASSERT_EQ(kUnknownError, ExecuteQuit(&map, &session, params, &value).code()); 178 ASSERT_EQ(kUnknownError, ExecuteQuit(&map, &session, params, &value).code());
176 ASSERT_FALSE(map.Has(session.id)); 179 ASSERT_FALSE(map.Has(session.id));
177 ASSERT_FALSE(value.get()); 180 ASSERT_FALSE(value.get());
178 } 181 }
OLDNEW
« no previous file with comments | « chrome/test/chromedriver/commands.cc ('k') | chrome/test/chromedriver/devtools_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698