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: Review Fixes Created 5 years 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(routes,
98 std::vector<MediaRoute::Id>());
97 99
98 // New route list does not contain |route_id|, which means it is disconnected. 100 // New route list does not contain |route_id|, which means it is disconnected.
99 EXPECT_CALL(*this, OnSessionStateChanged( 101 EXPECT_CALL(*this, OnSessionStateChanged(
100 PresentationSessionInfoEquals(session_info), 102 PresentationSessionInfoEquals(session_info),
101 content::PRESENTATION_SESSION_STATE_DISCONNECTED)); 103 content::PRESENTATION_SESSION_STATE_DISCONNECTED));
102 observer_->OnRoutesUpdated(std::vector<MediaRoute>()); 104 observer_->OnRoutesUpdated(std::vector<MediaRoute>(),
105 std::vector<MediaRoute::Id>());
103 106
104 // Note that it is normally not possible for |route_id| to reappear. But in 107 // 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. 108 // case it does, test that it does NOT invoke the callback with CONNECTED.
106 EXPECT_TRUE(testing::Mock::VerifyAndClearExpectations(this)); 109 EXPECT_TRUE(testing::Mock::VerifyAndClearExpectations(this));
107 observer_->OnRoutesUpdated(routes); 110 observer_->OnRoutesUpdated(routes,
111 std::vector<MediaRoute::Id>());
108 } 112 }
109 113
110 TEST_F(PresentationSessionStateObserverTest, Reset) { 114 TEST_F(PresentationSessionStateObserverTest, Reset) {
111 content::PresentationSessionInfo session_info(kPresentationUrl, 115 content::PresentationSessionInfo session_info(kPresentationUrl,
112 kPresentationId); 116 kPresentationId);
113 EXPECT_CALL(*this, OnSessionStateChanged( 117 EXPECT_CALL(*this, OnSessionStateChanged(
114 PresentationSessionInfoEquals(session_info), 118 PresentationSessionInfoEquals(session_info),
115 content::PRESENTATION_SESSION_STATE_CONNECTED)); 119 content::PRESENTATION_SESSION_STATE_CONNECTED));
116 MediaRoute::Id route_id(CreateRouteId(kPresentationUrl, kPresentationId)); 120 MediaRoute::Id route_id(CreateRouteId(kPresentationUrl, kPresentationId));
117 observer_->OnPresentationSessionConnected(route_id); 121 observer_->OnPresentationSessionConnected(route_id);
118 122 MediaSource media_source = MediaSourceForPresentationUrl(kPresentationUrl);
119 // Route list update is expected to follow creation of route. 123 // Route list update is expected to follow creation of route.
120 std::vector<MediaRoute> routes; 124 std::vector<MediaRoute> routes;
121 routes.push_back(MediaRoute(route_id, 125 routes.push_back(MediaRoute(route_id,
122 MediaSourceForPresentationUrl(kPresentationUrl), 126 media_source,
123 "sinkId", "Description", true, "", false)); 127 "sinkId", "Description", true, "", false));
124 observer_->OnRoutesUpdated(routes); 128 observer_->OnRoutesUpdated(routes,
129 std::vector<MediaRoute::Id>());
125 130
126 // |route_id| is no longer being tracked. 131 // |route_id| is no longer being tracked.
127 observer_->Reset(); 132 observer_->Reset();
128 EXPECT_TRUE(testing::Mock::VerifyAndClearExpectations(this)); 133 EXPECT_TRUE(testing::Mock::VerifyAndClearExpectations(this));
129 observer_->OnRoutesUpdated(std::vector<MediaRoute>()); 134 observer_->OnRoutesUpdated(std::vector<MediaRoute>(),
135 std::vector<MediaRoute::Id>());
130 } 136 }
131 137
132 } // namespace media_router 138 } // namespace media_router
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698