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

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: . Created 8 years, 1 month 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
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..13540a633053dd7ecf94ff8d013b67839c6fa18e
--- /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.begin()));
chrisgao (Use stgao instead) 2012/12/01 08:37:19 How about using urls.back() instead?
kkania 2013/02/28 21:51:58 Done.
+}
+
+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}]");
+}

Powered by Google App Engine
This is Rietveld 408576698