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

Unified Diff: third_party/WebKit/Source/modules/presentation/PresentationRequestTest.cpp

Issue 2148643002: [Presentation API] Adds DOMString[] constructor to PresentationRequest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix LayoutTests Created 4 years, 5 months 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: third_party/WebKit/Source/modules/presentation/PresentationRequestTest.cpp
diff --git a/third_party/WebKit/Source/modules/presentation/PresentationRequestTest.cpp b/third_party/WebKit/Source/modules/presentation/PresentationRequestTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d3d01a8ccc9ab336865d160ebe9cdeb6ff3c958d
--- /dev/null
+++ b/third_party/WebKit/Source/modules/presentation/PresentationRequestTest.cpp
@@ -0,0 +1,56 @@
+// Copyright 2016 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 "modules/presentation/PresentationRequest.h"
+
+#include "bindings/core/v8/V8BindingForTesting.h"
+#include "core/dom/ExceptionCode.h"
+#include "platform/weborigin/KURL.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace blink {
+namespace {
+
+TEST(PresentationRequestTest, TestSingleUrlConstructor)
+{
+ V8TestingScope scope;
+ PresentationRequest* request = PresentationRequest::create(scope.getExecutionContext(), "https://example.com", scope.getExceptionState());
+ ASSERT_FALSE(scope.getExceptionState().hadException());
+ WTF::Vector<KURL> requestUrls = request->urls();
+ EXPECT_EQ(requestUrls.size(), static_cast<size_t>(1));
+ EXPECT_TRUE(requestUrls[0].isValid());
+ EXPECT_EQ(requestUrls[0].getString(), "https://example.com/");
+}
+
+TEST(PresentationRequestTest, TestMultipleUrlConstructor)
+{
+ V8TestingScope scope;
+ WTF::Vector<String> urls;
+ urls.append("https://example.com");
+ urls.append("cast://deadbeef?param=foo");
+
+ PresentationRequest* request = PresentationRequest::create(scope.getExecutionContext(), urls, scope.getExceptionState());
+ ASSERT_FALSE(scope.getExceptionState().hadException());
+ WTF::Vector<KURL> requestUrls = request->urls();
+ EXPECT_EQ(static_cast<size_t>(2), requestUrls.size());
+ EXPECT_TRUE(requestUrls[0].isValid());
+ EXPECT_EQ("https://example.com/", requestUrls[0].getString());
+ EXPECT_TRUE(requestUrls[1].isValid());
+ EXPECT_EQ("cast://deadbeef?param=foo", requestUrls[1].getString());
+}
+
+TEST(PresentationRequestTest, TestMultipleUrlConstructorInvalidUrl)
+{
+ V8TestingScope scope;
+ WTF::Vector<String> urls;
+ urls.append("https://example.com");
+ urls.append("");
+
+ PresentationRequest::create(scope.getExecutionContext(), urls, scope.getExceptionState());
+ EXPECT_TRUE(scope.getExceptionState().hadException());
+ EXPECT_EQ(V8TypeError, scope.getExceptionState().code());
+}
+
+} // anonymous namespace
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698