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

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

Issue 1132903002: [MediaRouter] Add implementation of PresentationServiceDelegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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 8
9 namespace media_router { 9 namespace media_router {
10 10
11 TEST(MediaSourcesTest, IsMirroringMediaSource) { 11 TEST(MediaSourcesTest, IsMirroringMediaSource) {
12 EXPECT_TRUE(IsMirroringMediaSource(ForTabMediaSource(123))); 12 EXPECT_TRUE(IsMirroringMediaSource(MediaSourceForTab(123)));
13 EXPECT_TRUE(IsMirroringMediaSource(ForDesktopMediaSource())); 13 EXPECT_TRUE(IsMirroringMediaSource(MediaSourceForDesktop()));
14 EXPECT_FALSE(IsMirroringMediaSource(ForCastAppMediaSource("CastApp"))); 14 EXPECT_FALSE(IsMirroringMediaSource(MediaSourceForCastApp("CastApp")));
15 EXPECT_FALSE(IsMirroringMediaSource(ForPresentationUrl("http://url"))); 15 EXPECT_FALSE(
16 IsMirroringMediaSource(MediaSourceForPresentationUrl("http://url")));
16 } 17 }
17 18
18 TEST(MediaSourcesTest, CreateMediaSource) { 19 TEST(MediaSourcesTest, CreateMediaSource) {
19 EXPECT_EQ("urn:x-org.chromium.media:source:tab:123", 20 EXPECT_EQ("urn:x-org.chromium.media:source:tab:123",
20 ForTabMediaSource(123).id()); 21 MediaSourceForTab(123).id());
21 EXPECT_EQ("urn:x-org.chromium.media:source:desktop", 22 EXPECT_EQ("urn:x-org.chromium.media:source:desktop",
22 ForDesktopMediaSource().id()); 23 MediaSourceForDesktop().id());
23 EXPECT_EQ("urn:x-com.google.cast:application:DEADBEEF", 24 EXPECT_EQ("urn:x-com.google.cast:application:DEADBEEF",
24 ForCastAppMediaSource("DEADBEEF").id()); 25 MediaSourceForCastApp("DEADBEEF").id());
25 EXPECT_EQ("http://example.com/", 26 EXPECT_EQ("http://example.com/",
26 ForPresentationUrl("http://example.com/").id()); 27 MediaSourceForPresentationUrl("http://example.com/").id());
27 } 28 }
28 29
29 TEST(MediaSourcesTest, IsValidMediaSource) { 30 TEST(MediaSourcesTest, IsValidMediaSource) {
30 EXPECT_TRUE(IsValidMediaSource(ForTabMediaSource(123))); 31 EXPECT_TRUE(IsValidMediaSource(MediaSourceForTab(123)));
31 EXPECT_TRUE(IsValidMediaSource(ForDesktopMediaSource())); 32 EXPECT_TRUE(IsValidMediaSource(MediaSourceForDesktop()));
32 EXPECT_TRUE(IsValidMediaSource(ForCastAppMediaSource("DEADBEEF"))); 33 EXPECT_TRUE(IsValidMediaSource(MediaSourceForCastApp("DEADBEEF")));
33 EXPECT_TRUE(IsValidMediaSource(ForPresentationUrl("http://example.com/"))); 34 EXPECT_TRUE(
34 EXPECT_TRUE(IsValidMediaSource(ForPresentationUrl("https://example.com/"))); 35 IsValidMediaSource(MediaSourceForPresentationUrl("http://example.com/")));
36 EXPECT_TRUE(IsValidMediaSource(
37 MediaSourceForPresentationUrl("https://example.com/")));
35 38
36 // Disallowed scheme 39 // Disallowed scheme
40 EXPECT_FALSE(IsValidMediaSource(
41 MediaSourceForPresentationUrl("file:///some/local/path")));
42 // Not a URL
37 EXPECT_FALSE( 43 EXPECT_FALSE(
38 IsValidMediaSource(ForPresentationUrl("file:///some/local/path"))); 44 IsValidMediaSource(MediaSourceForPresentationUrl("totally not a url")));
39 // Not a URL 45 }
40 EXPECT_FALSE(IsValidMediaSource(ForPresentationUrl("totally not a url"))); 46
47 TEST(MediaSourcesTest, PresentationUrlFromMediaSource) {
48 EXPECT_EQ("", PresentationUrlFromMediaSource(MediaSourceForTab(123)));
49 EXPECT_EQ("", PresentationUrlFromMediaSource(MediaSourceForDesktop()));
50 EXPECT_EQ("http://example.com/",
51 PresentationUrlFromMediaSource(
52 MediaSourceForPresentationUrl("http://example.com/")));
41 } 53 }
42 54
43 } // namespace media_router 55 } // namespace media_router
44 56
OLDNEW
« no previous file with comments | « chrome/browser/media/router/media_source_helper.cc ('k') | chrome/browser/media/router/presentation_media_sinks_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698