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
3 // found in the LICENSE file.
5 #include "chrome/browser/media/router/media_source.h"
6 #include "chrome/browser/media/router/media_source_helper.h"
7 #include "testing/gtest/include/gtest/gtest.h"
9 namespace media_router
{
11 TEST(MediaSourcesTest
, IsMirroringMediaSource
) {
12 EXPECT_TRUE(IsMirroringMediaSource(MediaSourceForTab(123)));
13 EXPECT_TRUE(IsMirroringMediaSource(MediaSourceForDesktop()));
14 EXPECT_FALSE(IsMirroringMediaSource(MediaSourceForCastApp("CastApp")));
16 IsMirroringMediaSource(MediaSourceForPresentationUrl("http://url")));
19 TEST(MediaSourcesTest
, CreateMediaSource
) {
20 EXPECT_EQ("urn:x-org.chromium.media:source:tab:123",
21 MediaSourceForTab(123).id());
22 EXPECT_EQ("urn:x-org.chromium.media:source:desktop",
23 MediaSourceForDesktop().id());
24 EXPECT_EQ("urn:x-com.google.cast:application:DEADBEEF",
25 MediaSourceForCastApp("DEADBEEF").id());
26 EXPECT_EQ("http://example.com/",
27 MediaSourceForPresentationUrl("http://example.com/").id());
30 TEST(MediaSourcesTest
, IsValidMediaSource
) {
31 EXPECT_TRUE(IsValidMediaSource(MediaSourceForTab(123)));
32 EXPECT_TRUE(IsValidMediaSource(MediaSourceForDesktop()));
33 EXPECT_TRUE(IsValidMediaSource(MediaSourceForCastApp("DEADBEEF")));
35 IsValidMediaSource(MediaSourceForPresentationUrl("http://example.com/")));
36 EXPECT_TRUE(IsValidMediaSource(
37 MediaSourceForPresentationUrl("https://example.com/")));
40 EXPECT_FALSE(IsValidMediaSource(
41 MediaSourceForPresentationUrl("file:///some/local/path")));
44 IsValidMediaSource(MediaSourceForPresentationUrl("totally not a url")));
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/")));
55 } // namespace media_router