OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/media/router/media_route.h" | 5 #include "chrome/browser/media/router/media_route.h" |
6 #include "chrome/browser/media/router/media_sink.h" | 6 #include "chrome/browser/media/router/media_sink.h" |
7 #include "chrome/browser/media/router/media_source_helper.h" | 7 #include "chrome/browser/media/router/media_source_helper.h" |
8 #include "testing/gmock/include/gmock/gmock.h" | 8 #include "testing/gmock/include/gmock/gmock.h" |
9 | 9 |
10 namespace { | 10 namespace { |
11 const char kRouteId1[] = | 11 constexpr char kRouteId1[] = |
12 "urn:x-org.chromium:media:route:1/cast-sink1/http://foo.com"; | 12 "urn:x-org.chromium:media:route:1/cast-sink1/http://foo.com"; |
13 const char kRouteId2[] = | 13 constexpr char kRouteId2[] = |
14 "urn:x-org.chromium:media:route:2/cast-sink2/http://foo.com"; | 14 "urn:x-org.chromium:media:route:2/cast-sink2/http://foo.com"; |
| 15 constexpr char kPresentationUrl[] = "http://www.example.com/presentation.html"; |
15 } // namespace | 16 } // namespace |
16 | 17 |
17 namespace media_router { | 18 namespace media_router { |
18 | 19 |
19 // Tests the == operator to ensure that only route ID equality is being checked. | 20 // Tests the == operator to ensure that only route ID equality is being checked. |
20 TEST(MediaRouteTest, Equals) { | 21 TEST(MediaRouteTest, Equals) { |
21 MediaRoute route1(kRouteId1, MediaSourceForCastApp("DialApp"), "sinkId", | 22 const MediaSource& media_source = |
22 "Description", false, "", false); | 23 MediaSourceForPresentationUrl(GURL(kPresentationUrl)); |
| 24 MediaRoute route1(kRouteId1, media_source, "sinkId", "Description", false, "", |
| 25 false); |
23 | 26 |
24 // Same as route1 with different sink ID. | 27 // Same as route1 with different sink ID. |
25 MediaRoute route2(kRouteId1, MediaSourceForCastApp("DialApp"), | 28 MediaRoute route2(kRouteId1, media_source, "differentSinkId", "Description", |
26 "differentSinkId", "Description", false, "", false); | 29 false, "", false); |
27 EXPECT_TRUE(route1.Equals(route2)); | 30 EXPECT_TRUE(route1.Equals(route2)); |
28 | 31 |
29 // Same as route1 with different description. | 32 // Same as route1 with different description. |
30 MediaRoute route3(kRouteId1, MediaSourceForCastApp("DialApp"), "sinkId", | 33 MediaRoute route3(kRouteId1, media_source, "sinkId", "differentDescription", |
31 "differentDescription", false, "", false); | 34 false, "", false); |
32 EXPECT_TRUE(route1.Equals(route3)); | 35 EXPECT_TRUE(route1.Equals(route3)); |
33 | 36 |
34 // Same as route1 with different is_local. | 37 // Same as route1 with different is_local. |
35 MediaRoute route4(kRouteId1, MediaSourceForCastApp("DialApp"), "sinkId", | 38 MediaRoute route4(kRouteId1, media_source, "sinkId", "Description", true, "", |
36 "Description", true, "", false); | 39 false); |
37 EXPECT_TRUE(route1.Equals(route4)); | 40 EXPECT_TRUE(route1.Equals(route4)); |
38 | 41 |
39 // The ID is different from route1's. | 42 // The ID is different from route1's. |
40 MediaRoute route5(kRouteId2, MediaSourceForCastApp("DialApp"), "sinkId", | 43 MediaRoute route5(kRouteId2, media_source, "sinkId", "Description", false, "", |
41 "Description", false, "", false); | 44 false); |
42 EXPECT_FALSE(route1.Equals(route5)); | 45 EXPECT_FALSE(route1.Equals(route5)); |
43 | 46 |
44 // Same as route1 with different incognito. | 47 // Same as route1 with different incognito. |
45 MediaRoute route6(kRouteId1, MediaSourceForCastApp("DialApp"), "sinkId", | 48 MediaRoute route6(kRouteId1, media_source, "sinkId", "Description", true, "", |
46 "Description", true, "", false); | 49 false); |
47 route6.set_incognito(true); | 50 route6.set_incognito(true); |
48 EXPECT_TRUE(route1.Equals(route6)); | 51 EXPECT_TRUE(route1.Equals(route6)); |
49 } | 52 } |
50 | 53 |
51 } // namespace media_router | 54 } // namespace media_router |
OLD | NEW |