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(ForTabMediaSource(123)));
13 EXPECT_TRUE(IsMirroringMediaSource(ForDesktopMediaSource()));
14 EXPECT_FALSE(IsMirroringMediaSource(ForCastAppMediaSource("CastApp")));
15 EXPECT_FALSE(IsMirroringMediaSource(ForPresentationUrl("http://url")));
18 TEST(MediaSourcesTest
, CreateMediaSource
) {
19 EXPECT_EQ("urn:x-org.chromium.media:source:tab:123",
20 ForTabMediaSource(123).id());
21 EXPECT_EQ("urn:x-org.chromium.media:source:desktop",
22 ForDesktopMediaSource().id());
23 EXPECT_EQ("urn:x-com.google.cast:application:DEADBEEF",
24 ForCastAppMediaSource("DEADBEEF").id());
25 EXPECT_EQ("http://example.com/",
26 ForPresentationUrl("http://example.com/").id());
29 TEST(MediaSourcesTest
, IsValidMediaSource
) {
30 EXPECT_TRUE(IsValidMediaSource(ForTabMediaSource(123)));
31 EXPECT_TRUE(IsValidMediaSource(ForDesktopMediaSource()));
32 EXPECT_TRUE(IsValidMediaSource(ForCastAppMediaSource("DEADBEEF")));
33 EXPECT_TRUE(IsValidMediaSource(ForPresentationUrl("http://example.com/")));
34 EXPECT_TRUE(IsValidMediaSource(ForPresentationUrl("https://example.com/")));
38 IsValidMediaSource(ForPresentationUrl("file:///some/local/path")));
40 EXPECT_FALSE(IsValidMediaSource(ForPresentationUrl("totally not a url")));
43 } // namespace media_router