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

Side by Side Diff: chrome/test/chromedriver/chrome_impl_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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include <list>
6 #include <string>
7
8 #include "chrome/test/chromedriver/chrome_impl.h"
9 #include "chrome/test/chromedriver/status.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11
12 TEST(ParsePagesInfo, Normal) {
13 std::list<std::string> urls;
14 Status status = internal::ParsePagesInfo(
15 "[{\"webSocketDebuggerUrl\": \"http://debugurl\"}]",
16 &urls);
17 ASSERT_TRUE(status.IsOk());
18 ASSERT_EQ(1u, urls.size());
19 ASSERT_EQ("http://debugurl", urls.front());
20 }
21
22 TEST(ParsePagesInfo, Multiple) {
23 std::list<std::string> urls;
24 Status status = internal::ParsePagesInfo(
25 "[{\"webSocketDebuggerUrl\": \"http://debugurl\"},"
26 " {\"webSocketDebuggerUrl\": \"http://debugurl2\"}]",
27 &urls);
28 ASSERT_TRUE(status.IsOk());
29 ASSERT_EQ(2u, urls.size());
30 ASSERT_EQ("http://debugurl", urls.front());
31 ASSERT_EQ("http://debugurl2", urls.back());
32 }
33
34 namespace {
35
36 void AssertFails(const std::string& data) {
37 std::list<std::string> urls;
38 Status status = internal::ParsePagesInfo(data, &urls);
39 ASSERT_FALSE(status.IsOk());
40 ASSERT_EQ(0u, urls.size());
41 }
42
43 } // namespace
44
45 TEST(ParsePagesInfo, InvalidJSON) {
46 AssertFails("[");
47 }
48
49 TEST(ParsePagesInfo, NonList) {
50 AssertFails("{}");
51 }
52
53 TEST(ParsePagesInfo, NonDictionary) {
54 AssertFails("[1]");
55 }
56
57 TEST(ParsePagesInfo, NoDebuggerUrl) {
58 AssertFails("[{\"hi\": 1}]");
59 }
60
61 TEST(ParsePagesInfo, InvalidDebuggerUrl) {
62 AssertFails("[{\"webSocketDebuggerUrl\": 1}]");
63 }
OLDNEW
« no previous file with comments | « chrome/test/chromedriver/chrome_impl.cc ('k') | chrome/test/chromedriver/chrome_launcher_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698