Fire an error if a pref used in the UI is missing once all prefs are fetched.
[chromium-blink-merge.git] / chrome / browser / media / router / media_source_helper_unittest.cc
blobfe360465328fb133e007ced460e979d9f29dce0f
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/")));
36 // Disallowed scheme
37 EXPECT_FALSE(
38 IsValidMediaSource(ForPresentationUrl("file:///some/local/path")));
39 // Not a URL
40 EXPECT_FALSE(IsValidMediaSource(ForPresentationUrl("totally not a url")));
43 } // namespace media_router