Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(423)

Side by Side Diff: chrome/browser/media/router/presentation_session_state_observer_unittest.cc

Issue 1415103006: Non-Local Join for Media Router and Presentation API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added Unit Tests Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
8 #include "chrome/browser/media/router/media_route.h" 8 #include "chrome/browser/media/router/media_route.h"
9 #include "chrome/browser/media/router/media_source_helper.h" 9 #include "chrome/browser/media/router/media_source_helper.h"
10 #include "chrome/browser/media/router/mock_media_router.h" 10 #include "chrome/browser/media/router/mock_media_router.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 content::PresentationSessionInfo session_info(kPresentationUrl, 83 content::PresentationSessionInfo session_info(kPresentationUrl,
84 kPresentationId); 84 kPresentationId);
85 EXPECT_CALL(*this, OnSessionStateChanged( 85 EXPECT_CALL(*this, OnSessionStateChanged(
86 PresentationSessionInfoEquals(session_info), 86 PresentationSessionInfoEquals(session_info),
87 content::PRESENTATION_SESSION_STATE_CONNECTED)); 87 content::PRESENTATION_SESSION_STATE_CONNECTED));
88 MediaRoute::Id route_id(CreateRouteId(kPresentationUrl, kPresentationId)); 88 MediaRoute::Id route_id(CreateRouteId(kPresentationUrl, kPresentationId));
89 observer_->OnPresentationSessionConnected(route_id); 89 observer_->OnPresentationSessionConnected(route_id);
90 90
91 // Route list update is expected to follow creation of route. 91 // Route list update is expected to follow creation of route.
92 std::vector<MediaRoute> routes; 92 std::vector<MediaRoute> routes;
93 MediaSource media_source = MediaSourceForPresentationUrl(kPresentationUrl);
93 routes.push_back(MediaRoute(route_id, 94 routes.push_back(MediaRoute(route_id,
94 MediaSourceForPresentationUrl(kPresentationUrl), 95 media_source,
95 "sinkId", "Description", true, "", false)); 96 "sinkId", "Description", true, "", false));
96 observer_->OnRoutesUpdated(routes); 97 observer_->OnRoutesUpdated(media_source.id(),
98 routes,
99 std::vector<MediaRoute>());
97 100
98 // New route list does not contain |route_id|, which means it is disconnected. 101 // New route list does not contain |route_id|, which means it is disconnected.
99 EXPECT_CALL(*this, OnSessionStateChanged( 102 EXPECT_CALL(*this, OnSessionStateChanged(
100 PresentationSessionInfoEquals(session_info), 103 PresentationSessionInfoEquals(session_info),
101 content::PRESENTATION_SESSION_STATE_DISCONNECTED)); 104 content::PRESENTATION_SESSION_STATE_DISCONNECTED));
102 observer_->OnRoutesUpdated(std::vector<MediaRoute>()); 105 observer_->OnRoutesUpdated(media_source.id(),
106 std::vector<MediaRoute>(), std::vector<MediaRoute>());
103 107
104 // Note that it is normally not possible for |route_id| to reappear. But in 108 // Note that it is normally not possible for |route_id| to reappear. But in
105 // case it does, test that it does NOT invoke the callback with CONNECTED. 109 // case it does, test that it does NOT invoke the callback with CONNECTED.
106 EXPECT_TRUE(testing::Mock::VerifyAndClearExpectations(this)); 110 EXPECT_TRUE(testing::Mock::VerifyAndClearExpectations(this));
107 observer_->OnRoutesUpdated(routes); 111 observer_->OnRoutesUpdated(media_source.id(),
112 routes,
113 std::vector<MediaRoute>());
108 } 114 }
109 115
110 TEST_F(PresentationSessionStateObserverTest, Reset) { 116 TEST_F(PresentationSessionStateObserverTest, Reset) {
111 content::PresentationSessionInfo session_info(kPresentationUrl, 117 content::PresentationSessionInfo session_info(kPresentationUrl,
112 kPresentationId); 118 kPresentationId);
113 EXPECT_CALL(*this, OnSessionStateChanged( 119 EXPECT_CALL(*this, OnSessionStateChanged(
114 PresentationSessionInfoEquals(session_info), 120 PresentationSessionInfoEquals(session_info),
115 content::PRESENTATION_SESSION_STATE_CONNECTED)); 121 content::PRESENTATION_SESSION_STATE_CONNECTED));
116 MediaRoute::Id route_id(CreateRouteId(kPresentationUrl, kPresentationId)); 122 MediaRoute::Id route_id(CreateRouteId(kPresentationUrl, kPresentationId));
117 observer_->OnPresentationSessionConnected(route_id); 123 observer_->OnPresentationSessionConnected(route_id);
118 124 MediaSource media_source = MediaSourceForPresentationUrl(kPresentationUrl);
119 // Route list update is expected to follow creation of route. 125 // Route list update is expected to follow creation of route.
120 std::vector<MediaRoute> routes; 126 std::vector<MediaRoute> routes;
121 routes.push_back(MediaRoute(route_id, 127 routes.push_back(MediaRoute(route_id,
122 MediaSourceForPresentationUrl(kPresentationUrl), 128 media_source,
123 "sinkId", "Description", true, "", false)); 129 "sinkId", "Description", true, "", false));
124 observer_->OnRoutesUpdated(routes); 130 observer_->OnRoutesUpdated(media_source.id(),
131 routes,
132 std::vector<MediaRoute>());
125 133
126 // |route_id| is no longer being tracked. 134 // |route_id| is no longer being tracked.
127 observer_->Reset(); 135 observer_->Reset();
128 EXPECT_TRUE(testing::Mock::VerifyAndClearExpectations(this)); 136 EXPECT_TRUE(testing::Mock::VerifyAndClearExpectations(this));
129 observer_->OnRoutesUpdated(std::vector<MediaRoute>()); 137 observer_->OnRoutesUpdated(media_source.id(),
138 std::vector<MediaRoute>(),
139 std::vector<MediaRoute>());
130 } 140 }
131 141
132 } // namespace media_router 142 } // namespace media_router
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698