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

Side by Side Diff: chrome/browser/media/router/media_source_helper_unittest.cc

Issue 2386633003: [Media Router] Convert MediaRouter to use GURL for presentation URLs. (Closed)
Patch Set: Respond to dcheng@ comment Created 4 years, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/media/router/media_source.h" 5 #include "chrome/browser/media/router/media_source.h"
6 #include "chrome/browser/media/router/media_source_helper.h" 6 #include "chrome/browser/media/router/media_source_helper.h"
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "url/gurl.h"
8 9
9 namespace media_router { 10 namespace media_router {
10 11
12 constexpr char kPresentationUrl[] = "http://www.example.com/presentation.html";
13
11 TEST(MediaSourcesTest, IsMirroringMediaSource) { 14 TEST(MediaSourcesTest, IsMirroringMediaSource) {
12 EXPECT_TRUE(IsTabMirroringMediaSource(MediaSourceForTab(123))); 15 EXPECT_TRUE(IsTabMirroringMediaSource(MediaSourceForTab(123)));
13 EXPECT_TRUE(IsDesktopMirroringMediaSource(MediaSourceForDesktop())); 16 EXPECT_TRUE(IsDesktopMirroringMediaSource(MediaSourceForDesktop()));
14 EXPECT_TRUE(IsMirroringMediaSource(MediaSourceForTab(123))); 17 EXPECT_TRUE(IsMirroringMediaSource(MediaSourceForTab(123)));
15 EXPECT_TRUE(IsMirroringMediaSource(MediaSourceForDesktop())); 18 EXPECT_TRUE(IsMirroringMediaSource(MediaSourceForDesktop()));
16 EXPECT_FALSE(IsMirroringMediaSource(MediaSourceForCastApp("CastApp"))); 19 EXPECT_FALSE(IsMirroringMediaSource(
17 EXPECT_FALSE( 20 MediaSourceForPresentationUrl(GURL(kPresentationUrl))));
18 IsMirroringMediaSource(MediaSourceForPresentationUrl("http://url")));
19 } 21 }
20 22
21 TEST(MediaSourcesTest, CreateMediaSource) { 23 TEST(MediaSourcesTest, CreateMediaSource) {
22 EXPECT_EQ("urn:x-org.chromium.media:source:tab:123", 24 EXPECT_EQ("urn:x-org.chromium.media:source:tab:123",
23 MediaSourceForTab(123).id()); 25 MediaSourceForTab(123).id());
24 EXPECT_EQ("urn:x-org.chromium.media:source:desktop", 26 EXPECT_EQ("urn:x-org.chromium.media:source:desktop",
25 MediaSourceForDesktop().id()); 27 MediaSourceForDesktop().id());
26 EXPECT_EQ("urn:x-com.google.cast:application:DEADBEEF", 28 EXPECT_EQ(kPresentationUrl,
27 MediaSourceForCastApp("DEADBEEF").id()); 29 MediaSourceForPresentationUrl(GURL(kPresentationUrl)).id());
28 EXPECT_EQ("http://example.com/",
29 MediaSourceForPresentationUrl("http://example.com/").id());
30 } 30 }
31 31
32 TEST(MediaSourcesTest, IsValidMediaSource) { 32 TEST(MediaSourcesTest, IsValidMediaSource) {
33 EXPECT_TRUE(IsValidMediaSource(MediaSourceForTab(123))); 33 EXPECT_TRUE(IsValidMediaSource(MediaSourceForTab(123)));
34 EXPECT_TRUE(IsValidMediaSource(MediaSourceForDesktop())); 34 EXPECT_TRUE(IsValidMediaSource(MediaSourceForDesktop()));
35 EXPECT_TRUE(IsValidMediaSource(MediaSourceForCastApp("DEADBEEF")));
36 EXPECT_TRUE(
37 IsValidMediaSource(MediaSourceForPresentationUrl("http://example.com/")));
38 EXPECT_TRUE(IsValidMediaSource( 35 EXPECT_TRUE(IsValidMediaSource(
39 MediaSourceForPresentationUrl("https://example.com/"))); 36 MediaSourceForPresentationUrl(GURL(kPresentationUrl))));
37 EXPECT_TRUE(IsValidMediaSource(
38 MediaSourceForPresentationUrl(GURL(kPresentationUrl))));
40 39
41 // Disallowed scheme 40 // Disallowed scheme
42 EXPECT_FALSE(IsValidMediaSource( 41 EXPECT_FALSE(IsValidMediaSource(
43 MediaSourceForPresentationUrl("file:///some/local/path"))); 42 MediaSourceForPresentationUrl(GURL("file:///some/local/path"))));
44 // Not a URL 43 // Not a URL
45 EXPECT_FALSE( 44 EXPECT_FALSE(IsValidMediaSource(
46 IsValidMediaSource(MediaSourceForPresentationUrl("totally not a url"))); 45 MediaSourceForPresentationUrl(GURL("totally not a url"))));
47 }
48
49 TEST(MediaSourcesTest, PresentationUrlFromMediaSource) {
50 EXPECT_EQ("", PresentationUrlFromMediaSource(MediaSourceForTab(123)));
51 EXPECT_EQ("", PresentationUrlFromMediaSource(MediaSourceForDesktop()));
52 EXPECT_EQ("http://example.com/",
53 PresentationUrlFromMediaSource(
54 MediaSourceForPresentationUrl("http://example.com/")));
55 } 46 }
56 47
57 } // namespace media_router 48 } // namespace media_router
58 49
OLDNEW
« no previous file with comments | « chrome/browser/media/router/media_source_helper.cc ('k') | chrome/browser/media/router/mock_screen_availability_listener.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698