Chromium Code Reviews| Index: chrome/browser/media/router/media_source_unittest.cc |
| diff --git a/chrome/browser/media/router/media_source_unittest.cc b/chrome/browser/media/router/media_source_unittest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ffbf312ed3c847de797f7b352652607cf0f26115 |
| --- /dev/null |
| +++ b/chrome/browser/media/router/media_source_unittest.cc |
| @@ -0,0 +1,41 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/media/router/media_source.h" |
| +#include "testing/gtest/include/gtest/gtest.h" |
| + |
| +namespace media_router { |
|
Kevin M
2015/03/09 23:32:06
Please take a look at media_sources.h.
|
| + |
| +TEST(MediaSourceTest, IsMirroringMediaSource) { |
| + EXPECT_TRUE(IsMirroringMediaSource(ForTabMediaSource(123))); |
| + EXPECT_TRUE(IsMirroringMediaSource(ForDesktopMediaSource())); |
| + EXPECT_FALSE(IsMirroringMediaSource(ForCastAppMediaSource("CastApp"))); |
| + EXPECT_FALSE(IsMirroringMediaSource(ForPresentationUrl("http://url"))); |
| +} |
| + |
| +TEST(MediaSourceTest, CreateMediaSource) { |
| + EXPECT_EQ("urn:x-org.chromium.media:source:tab:123", |
| + ForTabMediaSource(123)); |
| + EXPECT_EQ("urn:x-org.chromium.media:source:desktop", |
| + ForDesktopMediaSource()); |
| + EXPECT_EQ("urn:x-com.google.cast:application:DEADBEEF", |
| + 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
|
| + EXPECT_EQ("http://theoatmeal.com/", |
| + ForPresentationUrl("http://theoatmeal.com/")); |
| +} |
| + |
| +TEST(MediaSourceTest, IsValidMediaSource) { |
| + 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
|
| + EXPECT_TRUE(IsValidMediaSource(ForDesktopMediaSource())); |
| + EXPECT_TRUE(IsValidMediaSource(ForCastAppMediaSource("DEADBEEF"))); |
| + 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.
|
| + |
| + // Disallowed scheme |
| + EXPECT_FALSE( |
| + IsValidMediaSource(ForPresentationUrl("file:///some/local/path"))); |
| + // Not a URL |
| + EXPECT_FALSE(IsValidMediaSource(ForPresentationUrl("exploding kittens"))); |
| +} |
| + |
| +} // namespace media_router |