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_route.h" |
| 6 #include "testing/gmock/include/gmock/gmock.h" |
| 7 |
| 8 namespace media_router { |
| 9 |
| 10 class MediaRouteTest : public ::testing::Test { |
| 11 protected: |
| 12 MediaRouteTest() {} |
| 13 ~MediaRouteTest() override {} |
| 14 |
| 15 private: |
| 16 DISALLOW_COPY_AND_ASSIGN(MediaRouteTest); |
| 17 }; |
| 18 |
| 19 |
| 20 TEST_F(MediaRouteTest, MediaRouteResponseSuccess) { |
| 21 MediaSource source = media_router::ForDialAppMediaSource("someApp"); |
| 22 MediaRoute route( |
| 23 "routeId", source, "sinkId", "A route", true); |
| 24 |
| 25 RouteRequestId request_id = 123; |
| 26 scoped_ptr<MediaRouteResponse> response = |
| 27 MediaRouteResponse::Success(request_id, route); |
| 28 |
| 29 EXPECT_EQ(request_id, response->request_id()); |
| 30 const MediaRoute* response_route = response->route(); |
| 31 ASSERT_TRUE(response_route); |
| 32 EXPECT_EQ(route, *response_route); |
| 33 EXPECT_TRUE(response->error().empty()); |
| 34 } |
| 35 |
| 36 TEST_F(MediaRouteTest, MediaRouteResponseError) { |
| 37 RouteRequestId request_id = 123; |
| 38 std::string error("Error reason"); |
| 39 scoped_ptr<MediaRouteResponse> response = |
| 40 MediaRouteResponse::Error(request_id, error); |
| 41 |
| 42 EXPECT_EQ(request_id, response->request_id()); |
| 43 EXPECT_EQ(error, response->error()); |
| 44 EXPECT_FALSE(response->route()); |
| 45 } |
| 46 |
| 47 // Tests the == operator. |
| 48 TEST_F(MediaRouteTest, Equals) { |
| 49 MediaRoute route1("routeId1", |
| 50 ForDialAppMediaSource("DialApp"), "sinkId", "Description", false); |
| 51 |
| 52 // Same as route1. |
| 53 MediaRoute route2("routeId1", |
| 54 ForDialAppMediaSource("DialApp"), "sinkId", "Description", false); |
| 55 EXPECT_EQ(route1, route2); |
| 56 |
| 57 // The ID is different from route1's. |
| 58 MediaRoute route3("routeId2", |
| 59 ForDialAppMediaSource("DialApp"), "sinkId", "Description", false); |
| 60 EXPECT_NE(route1, route3); |
| 61 |
| 62 // The MediaSource is different from route1's. |
| 63 MediaRoute route4("routeId2", |
| 64 ForDesktopMediaSource(), "sinkId", "Description", false); |
| 65 EXPECT_NE(route1, route4); |
| 66 |
| 67 // The sink ID is different from route1's. |
| 68 MediaRoute route5("routeId2", |
| 69 ForDialAppMediaSource("DialApp"), "anotherSinkId", "Description", false); |
| 70 EXPECT_NE(route1, route5); |
| 71 } |
| 72 |
| 73 } // namespace media_router |
OLD | NEW |