Index: chrome/browser/media/router/media_route_unittest.cc |
diff --git a/chrome/browser/media/router/media_route_unittest.cc b/chrome/browser/media/router/media_route_unittest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..07c849236b87e4306255c279a759a02ced717b9d |
--- /dev/null |
+++ b/chrome/browser/media/router/media_route_unittest.cc |
@@ -0,0 +1,73 @@ |
+// 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_route.h" |
+#include "testing/gmock/include/gmock/gmock.h" |
+ |
+namespace media_router { |
+ |
+class MediaRouteTest : public ::testing::Test { |
+ protected: |
+ MediaRouteTest() {} |
+ ~MediaRouteTest() override {} |
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(MediaRouteTest); |
+}; |
+ |
+ |
+TEST_F(MediaRouteTest, MediaRouteResponseSuccess) { |
+ MediaSource source = media_router::ForDialAppMediaSource("someApp"); |
+ MediaRoute route( |
+ "routeId", source, "sinkId", "A route", true); |
+ |
+ RouteRequestId request_id = 123; |
+ scoped_ptr<MediaRouteResponse> response = |
+ MediaRouteResponse::Success(request_id, route); |
+ |
+ EXPECT_EQ(request_id, response->request_id()); |
+ const MediaRoute* response_route = response->route(); |
+ ASSERT_TRUE(response_route); |
+ EXPECT_EQ(route, *response_route); |
+ EXPECT_TRUE(response->error().empty()); |
+} |
+ |
+TEST_F(MediaRouteTest, MediaRouteResponseError) { |
+ RouteRequestId request_id = 123; |
+ std::string error("Error reason"); |
+ scoped_ptr<MediaRouteResponse> response = |
+ MediaRouteResponse::Error(request_id, error); |
+ |
+ EXPECT_EQ(request_id, response->request_id()); |
+ EXPECT_EQ(error, response->error()); |
+ EXPECT_FALSE(response->route()); |
+} |
+ |
+// Tests the == operator. |
+TEST_F(MediaRouteTest, Equals) { |
+ MediaRoute route1("routeId1", |
+ ForDialAppMediaSource("DialApp"), "sinkId", "Description", false); |
+ |
+ // Same as route1. |
+ MediaRoute route2("routeId1", |
+ ForDialAppMediaSource("DialApp"), "sinkId", "Description", false); |
+ EXPECT_EQ(route1, route2); |
+ |
+ // The ID is different from route1's. |
+ MediaRoute route3("routeId2", |
+ ForDialAppMediaSource("DialApp"), "sinkId", "Description", false); |
+ EXPECT_NE(route1, route3); |
+ |
+ // The MediaSource is different from route1's. |
+ MediaRoute route4("routeId2", |
+ ForDesktopMediaSource(), "sinkId", "Description", false); |
+ EXPECT_NE(route1, route4); |
+ |
+ // The sink ID is different from route1's. |
+ MediaRoute route5("routeId2", |
+ ForDialAppMediaSource("DialApp"), "anotherSinkId", "Description", false); |
+ EXPECT_NE(route1, route5); |
+} |
+ |
+} // namespace media_router |