Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 "testing/gtest/include/gtest/gtest.h" | |
| 7 | |
| 8 namespace media_router { | |
|
Kevin M
2015/03/09 23:32:06
Please take a look at media_sources.h.
| |
| 9 | |
| 10 TEST(MediaSourceTest, IsMirroringMediaSource) { | |
| 11 EXPECT_TRUE(IsMirroringMediaSource(ForTabMediaSource(123))); | |
| 12 EXPECT_TRUE(IsMirroringMediaSource(ForDesktopMediaSource())); | |
| 13 EXPECT_FALSE(IsMirroringMediaSource(ForCastAppMediaSource("CastApp"))); | |
| 14 EXPECT_FALSE(IsMirroringMediaSource(ForPresentationUrl("http://url"))); | |
| 15 } | |
| 16 | |
| 17 TEST(MediaSourceTest, CreateMediaSource) { | |
| 18 EXPECT_EQ("urn:x-org.chromium.media:source:tab:123", | |
| 19 ForTabMediaSource(123)); | |
| 20 EXPECT_EQ("urn:x-org.chromium.media:source:desktop", | |
| 21 ForDesktopMediaSource()); | |
| 22 EXPECT_EQ("urn:x-com.google.cast:application:DEADBEEF", | |
| 23 ForCastAppMediaSource("DEADBEEF")); | |
|
xhwang
2015/03/05 22:28:50
Does this has to be a hex string? What anout XYZ?
Kevin M
2015/03/06 23:12:45
Yes it does.
xhwang
2015/03/09 17:37:30
Add a test case for XYZ then?
Kevin M
2015/03/09 23:32:06
Protocol-specific ID syntax validation takes place
| |
| 24 EXPECT_EQ("http://theoatmeal.com/", | |
| 25 ForPresentationUrl("http://theoatmeal.com/")); | |
| 26 } | |
| 27 | |
| 28 TEST(MediaSourceTest, IsValidMediaSource) { | |
| 29 EXPECT_TRUE(IsValidMediaSource(ForTabMediaSource(123))); | |
|
xhwang
2015/03/05 22:28:50
How about urn:x-org.chromium.media:source:tab:foo?
Kevin M
2015/03/06 23:12:45
Done.
Kevin M
2015/03/09 23:32:06
Sorry, didn't mean to mark this as done.
This is
| |
| 30 EXPECT_TRUE(IsValidMediaSource(ForDesktopMediaSource())); | |
| 31 EXPECT_TRUE(IsValidMediaSource(ForCastAppMediaSource("DEADBEEF"))); | |
| 32 EXPECT_TRUE(IsValidMediaSource(ForPresentationUrl("http://theoatmeal.com/"))); | |
|
xhwang
2015/03/05 22:28:50
Also test https?
Kevin M
2015/03/06 23:12:45
Done.
| |
| 33 | |
| 34 // Disallowed scheme | |
| 35 EXPECT_FALSE( | |
| 36 IsValidMediaSource(ForPresentationUrl("file:///some/local/path"))); | |
| 37 // Not a URL | |
| 38 EXPECT_FALSE(IsValidMediaSource(ForPresentationUrl("exploding kittens"))); | |
| 39 } | |
| 40 | |
| 41 } // namespace media_router | |
| OLD | NEW |