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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/chromedriver/chrome_impl_unittest.cc
diff --git a/chrome/test/chromedriver/chrome_impl_unittest.cc b/chrome/test/chromedriver/chrome_impl_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..70f0ea4341155a88af5386c302d8e4bd67983ce1
--- /dev/null
+++ b/chrome/test/chromedriver/chrome_impl_unittest.cc
@@ -0,0 +1,63 @@
+// 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 "chrome/test/chromedriver/chrome_impl.h"
+#include "chrome/test/chromedriver/status.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+TEST(ParsePagesInfo, Normal) {
+ std::list<std::string> urls;
+ Status status = internal::ParsePagesInfo(
+ "[{\"webSocketDebuggerUrl\": \"http://debugurl\"}]",
+ &urls);
+ ASSERT_TRUE(status.IsOk());
+ ASSERT_EQ(1u, urls.size());
+ ASSERT_EQ("http://debugurl", urls.front());
+}
+
+TEST(ParsePagesInfo, Multiple) {
+ std::list<std::string> urls;
+ Status status = internal::ParsePagesInfo(
+ "[{\"webSocketDebuggerUrl\": \"http://debugurl\"},"
+ " {\"webSocketDebuggerUrl\": \"http://debugurl2\"}]",
+ &urls);
+ ASSERT_TRUE(status.IsOk());
+ ASSERT_EQ(2u, urls.size());
+ ASSERT_EQ("http://debugurl", urls.front());
+ ASSERT_EQ("http://debugurl2", urls.back());
+}
+
+namespace {
+
+void AssertFails(const std::string& data) {
+ std::list<std::string> urls;
+ Status status = internal::ParsePagesInfo(data, &urls);
+ ASSERT_FALSE(status.IsOk());
+ ASSERT_EQ(0u, urls.size());
+}
+
+} // namespace
+
+TEST(ParsePagesInfo, InvalidJSON) {
+ AssertFails("[");
+}
+
+TEST(ParsePagesInfo, NonList) {
+ AssertFails("{}");
+}
+
+TEST(ParsePagesInfo, NonDictionary) {
+ AssertFails("[1]");
+}
+
+TEST(ParsePagesInfo, NoDebuggerUrl) {
+ AssertFails("[{\"hi\": 1}]");
+}
+
+TEST(ParsePagesInfo, InvalidDebuggerUrl) {
+ AssertFails("[{\"webSocketDebuggerUrl\": 1}]");
+}
« 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