Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 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 "modules/presentation/PresentationRequest.h" | |
| 6 | |
| 7 #include "bindings/core/v8/V8BindingForTesting.h" | |
| 8 #include "core/dom/ExceptionCode.h" | |
| 9 #include "platform/weborigin/KURL.h" | |
| 10 #include "testing/gtest/include/gtest/gtest.h" | |
| 11 | |
| 12 namespace blink { | |
| 13 namespace { | |
| 14 | |
| 15 TEST(PresentationRequestTest, TestSingleUrlConstructor) | |
| 16 { | |
| 17 V8TestingScope scope; | |
| 18 PresentationRequest* request = PresentationRequest::create(scope.getExecutio nContext(), "https://example.com", scope.getExceptionState()); | |
| 19 ASSERT_FALSE(scope.getExceptionState().hadException()); | |
| 20 WTF::Vector<KURL> requestUrls = request->urls(); | |
| 21 EXPECT_EQ(requestUrls.size(), static_cast<size_t>(1)); | |
| 22 EXPECT_TRUE(requestUrls[0].isValid()); | |
| 23 EXPECT_EQ(requestUrls[0].getString(), "https://example.com/"); | |
| 24 } | |
| 25 | |
| 26 TEST(PresentationRequestTest, TestMultipleUrlConstructor) | |
| 27 { | |
| 28 V8TestingScope scope; | |
| 29 WTF::Vector<String> urls; | |
| 30 urls.append("https://example.com"); | |
| 31 urls.append("cast://google.com/appid=deadbeef"); | |
|
mlamouri (slow - plz ping)
2016/07/19 12:45:03
I'm genuinely surprised this is a valid URL :) I w
mark a. foltz
2016/07/19 17:38:47
Changed to cast:://deadbeef?param=foo and the test
| |
| 32 | |
| 33 PresentationRequest* request = PresentationRequest::create(scope.getExecutio nContext(), urls, scope.getExceptionState()); | |
| 34 ASSERT_FALSE(scope.getExceptionState().hadException()); | |
| 35 WTF::Vector<KURL> requestUrls = request->urls(); | |
| 36 EXPECT_EQ(static_cast<size_t>(2), requestUrls.size()); | |
| 37 EXPECT_TRUE(requestUrls[0].isValid()); | |
| 38 EXPECT_EQ("https://example.com/", requestUrls[0].getString()); | |
| 39 EXPECT_TRUE(requestUrls[1].isValid()); | |
| 40 EXPECT_EQ("cast://google.com/appid=deadbeef", requestUrls[1].getString()); | |
| 41 } | |
| 42 | |
| 43 TEST(PresentationRequestTest, TestMultipleUrlConstructorInvalidUrl) | |
| 44 { | |
| 45 V8TestingScope scope; | |
| 46 WTF::Vector<String> urls; | |
| 47 urls.append("https://example.com"); | |
| 48 urls.append(""); | |
| 49 | |
| 50 PresentationRequest::create(scope.getExecutionContext(), urls, scope.getExce ptionState()); | |
| 51 EXPECT_TRUE(scope.getExceptionState().hadException()); | |
| 52 EXPECT_EQ(V8TypeError, scope.getExceptionState().code()); | |
| 53 } | |
| 54 | |
| 55 } // anonymous namespace | |
| 56 } // namespace blink | |
| OLD | NEW |