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

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

Issue 2771413003: Move c/b/media/router/mojo/*.mojom to chrome/common/media_router/mojo/*.mojom (Closed)
Patch Set: Rebase Created 3 years, 8 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
(Empty)
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.
4
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"
8 #include "url/gurl.h"
9
10 namespace media_router {
11
12 constexpr char kPresentationUrl[] = "http://www.example.com/presentation.html";
13
14 TEST(MediaSourcesTest, IsMirroringMediaSource) {
15 EXPECT_TRUE(IsTabMirroringMediaSource(MediaSourceForTab(123)));
16 EXPECT_TRUE(IsDesktopMirroringMediaSource(MediaSourceForDesktop()));
17 EXPECT_TRUE(IsMirroringMediaSource(MediaSourceForTab(123)));
18 EXPECT_TRUE(IsMirroringMediaSource(MediaSourceForDesktop()));
19 EXPECT_FALSE(IsMirroringMediaSource(
20 MediaSourceForPresentationUrl(GURL(kPresentationUrl))));
21 }
22
23 TEST(MediaSourcesTest, CreateMediaSource) {
24 EXPECT_EQ("urn:x-org.chromium.media:source:tab:123",
25 MediaSourceForTab(123).id());
26 EXPECT_EQ("urn:x-org.chromium.media:source:desktop",
27 MediaSourceForDesktop().id());
28 EXPECT_EQ(kPresentationUrl,
29 MediaSourceForPresentationUrl(GURL(kPresentationUrl)).id());
30 }
31
32 TEST(MediaSourcesTest, IsValidMediaSource) {
33 EXPECT_TRUE(IsValidMediaSource(MediaSourceForTab(123)));
34 EXPECT_TRUE(IsValidMediaSource(MediaSourceForDesktop()));
35 EXPECT_TRUE(IsValidMediaSource(
36 MediaSourceForPresentationUrl(GURL(kPresentationUrl))));
37 EXPECT_TRUE(IsValidMediaSource(
38 MediaSourceForPresentationUrl(GURL(kPresentationUrl))));
39
40 // Disallowed scheme
41 EXPECT_FALSE(IsValidMediaSource(
42 MediaSourceForPresentationUrl(GURL("file:///some/local/path"))));
43 // Not a URL
44 EXPECT_FALSE(IsValidMediaSource(
45 MediaSourceForPresentationUrl(GURL("totally not a url"))));
46 }
47
48 TEST(MediaSourcesTest, CanConnectToMediaSource) {
49 EXPECT_TRUE(CanConnectToMediaSource(
50 MediaSource(GURL("https://google.com/cast#__castAppId__=233637DE"))));
51 // false scheme
52 EXPECT_FALSE(CanConnectToMediaSource(
53 MediaSource(GURL("http://google.com/cast#__castAppId__=233637DE"))));
54 // false domain
55 EXPECT_FALSE(CanConnectToMediaSource(
56 MediaSource(GURL("https://google2.com/cast#__castAppId__=233637DE"))));
57 // empty path
58 EXPECT_FALSE(
59 CanConnectToMediaSource(MediaSource(GURL("https://www.google.com"))));
60 // false path
61 EXPECT_FALSE(CanConnectToMediaSource(
62 MediaSource(GURL("https://www.google.com/path"))));
63
64 EXPECT_FALSE(CanConnectToMediaSource(MediaSource(GURL(""))));
65 }
66
67 } // namespace media_router
68
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698