| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "content/browser/webrtc/webrtc_internals.h" | 5 #include "content/browser/webrtc/webrtc_internals.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 11 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
| 12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "content/browser/webrtc/webrtc_internals_ui_observer.h" | 13 #include "content/browser/webrtc/webrtc_internals_ui_observer.h" |
| 14 #include "content/public/test/test_browser_thread.h" | 14 #include "content/public/test/test_browser_thread.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 16 |
| 17 namespace content { | 17 namespace content { |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 static const char kContraints[] = "c"; | 21 static const char kContraints[] = "c"; |
| 22 static const char kRtcConfiguration[] = "r"; | 22 static const char kRtcConfiguration[] = "r"; |
| 23 static const char kUrl[] = "u"; | 23 static const char kUrl[] = "u"; |
| 24 | 24 |
| 25 class MockWebRtcInternalsProxy : public WebRTCInternalsUIObserver { | 25 class MockWebRtcInternalsProxy : public WebRTCInternalsUIObserver { |
| 26 public: | 26 public: |
| 27 MockWebRtcInternalsProxy() : loop_(nullptr) {} | 27 MockWebRtcInternalsProxy() : loop_(nullptr) {} |
| 28 explicit MockWebRtcInternalsProxy(base::RunLoop* loop) : loop_(loop) {} | 28 explicit MockWebRtcInternalsProxy(base::RunLoop* loop) : loop_(loop) {} |
| 29 | 29 |
| 30 const std::string& command() const { | 30 const std::string& command() const { return command_; } |
| 31 return command_; | |
| 32 } | |
| 33 | 31 |
| 34 base::Value* value() { | 32 base::Value* value() { return value_.get(); } |
| 35 return value_.get(); | |
| 36 } | |
| 37 | 33 |
| 38 private: | 34 private: |
| 39 void OnUpdate(const char* command, const base::Value* value) override { | 35 void OnUpdate(const char* command, const base::Value* value) override { |
| 40 command_ = command; | 36 command_ = command; |
| 41 value_.reset(value ? value->DeepCopy() : nullptr); | 37 value_.reset(value ? value->DeepCopy() : nullptr); |
| 42 if (loop_) | 38 if (loop_) |
| 43 loop_->Quit(); | 39 loop_->Quit(); |
| 44 } | 40 } |
| 45 | 41 |
| 46 std::string command_; | 42 std::string command_; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 }; | 105 }; |
| 110 | 106 |
| 111 TEST_F(WebRtcInternalsTest, AddRemoveObserver) { | 107 TEST_F(WebRtcInternalsTest, AddRemoveObserver) { |
| 112 base::RunLoop loop; | 108 base::RunLoop loop; |
| 113 MockWebRtcInternalsProxy observer(&loop); | 109 MockWebRtcInternalsProxy observer(&loop); |
| 114 WebRTCInternalsForTest webrtc_internals; | 110 WebRTCInternalsForTest webrtc_internals; |
| 115 webrtc_internals.AddObserver(&observer); | 111 webrtc_internals.AddObserver(&observer); |
| 116 | 112 |
| 117 webrtc_internals.RemoveObserver(&observer); | 113 webrtc_internals.RemoveObserver(&observer); |
| 118 // The observer should not get notified of this activity. | 114 // The observer should not get notified of this activity. |
| 119 webrtc_internals.OnAddPeerConnection( | 115 webrtc_internals.OnAddPeerConnection(0, 3, 4, kUrl, kRtcConfiguration, |
| 120 0, 3, 4, kUrl, kRtcConfiguration, kContraints); | 116 kContraints); |
| 121 | 117 |
| 122 BrowserThread::PostDelayedTask(BrowserThread::UI, FROM_HERE, | 118 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, loop.QuitClosure()); |
| 123 loop.QuitClosure(), | |
| 124 base::TimeDelta::FromMilliseconds(5)); | |
| 125 loop.Run(); | 119 loop.Run(); |
| 126 | 120 |
| 127 EXPECT_EQ("", observer.command()); | 121 EXPECT_EQ("", observer.command()); |
| 128 | 122 |
| 129 webrtc_internals.OnRemovePeerConnection(3, 4); | 123 webrtc_internals.OnRemovePeerConnection(3, 4); |
| 130 } | 124 } |
| 131 | 125 |
| 126 TEST_F(WebRtcInternalsTest, EnsureNoLogWhenNoObserver) { |
| 127 base::RunLoop loop; |
| 128 WebRTCInternalsForTest webrtc_internals; |
| 129 webrtc_internals.OnAddPeerConnection(0, 3, 4, kUrl, kRtcConfiguration, |
| 130 kContraints); |
| 131 webrtc_internals.OnUpdatePeerConnection(3, 4, "update_type", "update_value"); |
| 132 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, loop.QuitClosure()); |
| 133 loop.Run(); |
| 134 |
| 135 // Make sure we don't have a log entry since there was no observer. |
| 136 MockWebRtcInternalsProxy observer; |
| 137 webrtc_internals.UpdateObserver(&observer); |
| 138 EXPECT_EQ("updateAllPeerConnections", observer.command()); |
| 139 |
| 140 base::ListValue* list = nullptr; |
| 141 ASSERT_TRUE(observer.value()->GetAsList(&list)); |
| 142 EXPECT_EQ(1U, list->GetSize()); |
| 143 base::DictionaryValue* dict = nullptr; |
| 144 ASSERT_TRUE((*list->begin())->GetAsDictionary(&dict)); |
| 145 base::ListValue* log = nullptr; |
| 146 ASSERT_FALSE(dict->GetList("log", &log)); |
| 147 |
| 148 webrtc_internals.OnRemovePeerConnection(3, 4); |
| 149 } |
| 150 |
| 151 TEST_F(WebRtcInternalsTest, EnsureLogIsRemovedWhenObserverIsRemoved) { |
| 152 base::RunLoop loop; |
| 153 WebRTCInternalsForTest webrtc_internals; |
| 154 MockWebRtcInternalsProxy observer; |
| 155 webrtc_internals.AddObserver(&observer); |
| 156 webrtc_internals.OnAddPeerConnection(0, 3, 4, kUrl, kRtcConfiguration, |
| 157 kContraints); |
| 158 webrtc_internals.OnUpdatePeerConnection(3, 4, "update_type", "update_value"); |
| 159 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, loop.QuitClosure()); |
| 160 loop.Run(); |
| 161 |
| 162 // Make sure we have a log entry since there was an observer. |
| 163 webrtc_internals.UpdateObserver(&observer); |
| 164 EXPECT_EQ("updateAllPeerConnections", observer.command()); |
| 165 |
| 166 base::ListValue* list = nullptr; |
| 167 ASSERT_TRUE(observer.value()->GetAsList(&list)); |
| 168 EXPECT_EQ(1U, list->GetSize()); |
| 169 base::DictionaryValue* dict = nullptr; |
| 170 ASSERT_TRUE((*list->begin())->GetAsDictionary(&dict)); |
| 171 base::ListValue* log = nullptr; |
| 172 ASSERT_TRUE(dict->GetList("log", &log)); |
| 173 |
| 174 // Make sure we the log entry was removed when the last observer was removed. |
| 175 webrtc_internals.RemoveObserver(&observer); |
| 176 webrtc_internals.UpdateObserver(&observer); |
| 177 EXPECT_EQ("updateAllPeerConnections", observer.command()); |
| 178 |
| 179 ASSERT_TRUE(observer.value()->GetAsList(&list)); |
| 180 EXPECT_EQ(1U, list->GetSize()); |
| 181 ASSERT_TRUE((*list->begin())->GetAsDictionary(&dict)); |
| 182 ASSERT_FALSE(dict->GetList("log", &log)); |
| 183 |
| 184 webrtc_internals.OnRemovePeerConnection(3, 4); |
| 185 } |
| 186 |
| 132 TEST_F(WebRtcInternalsTest, SendAddPeerConnectionUpdate) { | 187 TEST_F(WebRtcInternalsTest, SendAddPeerConnectionUpdate) { |
| 133 base::RunLoop loop; | 188 base::RunLoop loop; |
| 134 MockWebRtcInternalsProxy observer(&loop); | 189 MockWebRtcInternalsProxy observer(&loop); |
| 135 WebRTCInternalsForTest webrtc_internals; | 190 WebRTCInternalsForTest webrtc_internals; |
| 136 webrtc_internals.AddObserver(&observer); | 191 webrtc_internals.AddObserver(&observer); |
| 137 webrtc_internals.OnAddPeerConnection( | 192 webrtc_internals.OnAddPeerConnection(0, 1, 2, kUrl, kRtcConfiguration, |
| 138 0, 1, 2, kUrl, kRtcConfiguration, kContraints); | 193 kContraints); |
| 139 | 194 |
| 140 loop.Run(); | 195 loop.Run(); |
| 141 | 196 |
| 142 ASSERT_EQ("addPeerConnection", observer.command()); | 197 ASSERT_EQ("addPeerConnection", observer.command()); |
| 143 | 198 |
| 144 base::DictionaryValue* dict = NULL; | 199 base::DictionaryValue* dict = NULL; |
| 145 EXPECT_TRUE(observer.value()->GetAsDictionary(&dict)); | 200 EXPECT_TRUE(observer.value()->GetAsDictionary(&dict)); |
| 146 | 201 |
| 147 VerifyInt(dict, "pid", 1); | 202 VerifyInt(dict, "pid", 1); |
| 148 VerifyInt(dict, "lid", 2); | 203 VerifyInt(dict, "lid", 2); |
| 149 VerifyString(dict, "url", kUrl); | 204 VerifyString(dict, "url", kUrl); |
| 150 VerifyString(dict, "rtcConfiguration", kRtcConfiguration); | 205 VerifyString(dict, "rtcConfiguration", kRtcConfiguration); |
| 151 VerifyString(dict, "constraints", kContraints); | 206 VerifyString(dict, "constraints", kContraints); |
| 152 | 207 |
| 153 webrtc_internals.RemoveObserver(&observer); | 208 webrtc_internals.RemoveObserver(&observer); |
| 154 webrtc_internals.OnRemovePeerConnection(1, 2); | 209 webrtc_internals.OnRemovePeerConnection(1, 2); |
| 155 } | 210 } |
| 156 | 211 |
| 157 TEST_F(WebRtcInternalsTest, SendRemovePeerConnectionUpdate) { | 212 TEST_F(WebRtcInternalsTest, SendRemovePeerConnectionUpdate) { |
| 158 base::RunLoop loop; | 213 base::RunLoop loop; |
| 159 MockWebRtcInternalsProxy observer(&loop); | 214 MockWebRtcInternalsProxy observer(&loop); |
| 160 WebRTCInternalsForTest webrtc_internals; | 215 WebRTCInternalsForTest webrtc_internals; |
| 161 webrtc_internals.AddObserver(&observer); | 216 webrtc_internals.AddObserver(&observer); |
| 162 webrtc_internals.OnAddPeerConnection( | 217 webrtc_internals.OnAddPeerConnection(0, 1, 2, kUrl, kRtcConfiguration, |
| 163 0, 1, 2, kUrl, kRtcConfiguration, kContraints); | 218 kContraints); |
| 164 webrtc_internals.OnRemovePeerConnection(1, 2); | 219 webrtc_internals.OnRemovePeerConnection(1, 2); |
| 165 | 220 |
| 166 loop.Run(); | 221 loop.Run(); |
| 167 | 222 |
| 168 ASSERT_EQ("removePeerConnection", observer.command()); | 223 ASSERT_EQ("removePeerConnection", observer.command()); |
| 169 | 224 |
| 170 base::DictionaryValue* dict = NULL; | 225 base::DictionaryValue* dict = NULL; |
| 171 EXPECT_TRUE(observer.value()->GetAsDictionary(&dict)); | 226 EXPECT_TRUE(observer.value()->GetAsDictionary(&dict)); |
| 172 | 227 |
| 173 VerifyInt(dict, "pid", 1); | 228 VerifyInt(dict, "pid", 1); |
| 174 VerifyInt(dict, "lid", 2); | 229 VerifyInt(dict, "lid", 2); |
| 175 | 230 |
| 176 webrtc_internals.RemoveObserver(&observer); | 231 webrtc_internals.RemoveObserver(&observer); |
| 177 } | 232 } |
| 178 | 233 |
| 179 TEST_F(WebRtcInternalsTest, SendUpdatePeerConnectionUpdate) { | 234 TEST_F(WebRtcInternalsTest, SendUpdatePeerConnectionUpdate) { |
| 180 base::RunLoop loop; | 235 base::RunLoop loop; |
| 181 MockWebRtcInternalsProxy observer(&loop); | 236 MockWebRtcInternalsProxy observer(&loop); |
| 182 WebRTCInternalsForTest webrtc_internals; | 237 WebRTCInternalsForTest webrtc_internals; |
| 183 webrtc_internals.AddObserver(&observer); | 238 webrtc_internals.AddObserver(&observer); |
| 184 webrtc_internals.OnAddPeerConnection( | 239 webrtc_internals.OnAddPeerConnection(0, 1, 2, kUrl, kRtcConfiguration, |
| 185 0, 1, 2, kUrl, kRtcConfiguration, kContraints); | 240 kContraints); |
| 186 | 241 |
| 187 const std::string update_type = "fakeType"; | 242 const std::string update_type = "fakeType"; |
| 188 const std::string update_value = "fakeValue"; | 243 const std::string update_value = "fakeValue"; |
| 189 webrtc_internals.OnUpdatePeerConnection( | 244 webrtc_internals.OnUpdatePeerConnection(1, 2, update_type, update_value); |
| 190 1, 2, update_type, update_value); | |
| 191 | 245 |
| 192 loop.Run(); | 246 loop.Run(); |
| 193 | 247 |
| 194 ASSERT_EQ("updatePeerConnection", observer.command()); | 248 ASSERT_EQ("updatePeerConnection", observer.command()); |
| 195 | 249 |
| 196 base::DictionaryValue* dict = NULL; | 250 base::DictionaryValue* dict = NULL; |
| 197 EXPECT_TRUE(observer.value()->GetAsDictionary(&dict)); | 251 EXPECT_TRUE(observer.value()->GetAsDictionary(&dict)); |
| 198 | 252 |
| 199 VerifyInt(dict, "pid", 1); | 253 VerifyInt(dict, "pid", 1); |
| 200 VerifyInt(dict, "lid", 2); | 254 VerifyInt(dict, "lid", 2); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 214 MockWebRtcInternalsProxy observer(&loop); | 268 MockWebRtcInternalsProxy observer(&loop); |
| 215 WebRTCInternalsForTest webrtc_internals; | 269 WebRTCInternalsForTest webrtc_internals; |
| 216 | 270 |
| 217 // Add one observer before "getUserMedia". | 271 // Add one observer before "getUserMedia". |
| 218 webrtc_internals.AddObserver(&observer); | 272 webrtc_internals.AddObserver(&observer); |
| 219 | 273 |
| 220 const int rid = 1; | 274 const int rid = 1; |
| 221 const int pid = 2; | 275 const int pid = 2; |
| 222 const std::string audio_constraint = "aaa"; | 276 const std::string audio_constraint = "aaa"; |
| 223 const std::string video_constraint = "vvv"; | 277 const std::string video_constraint = "vvv"; |
| 224 webrtc_internals.OnGetUserMedia( | 278 webrtc_internals.OnGetUserMedia(rid, pid, kUrl, true, true, audio_constraint, |
| 225 rid, pid, kUrl, true, true, audio_constraint, video_constraint); | 279 video_constraint); |
| 226 | 280 |
| 227 loop.Run(); | 281 loop.Run(); |
| 228 | 282 |
| 229 ASSERT_EQ("addGetUserMedia", observer.command()); | 283 ASSERT_EQ("addGetUserMedia", observer.command()); |
| 230 VerifyGetUserMediaData( | 284 VerifyGetUserMediaData(observer.value(), rid, pid, kUrl, audio_constraint, |
| 231 observer.value(), rid, pid, kUrl, audio_constraint, video_constraint); | 285 video_constraint); |
| 232 | 286 |
| 233 webrtc_internals.RemoveObserver(&observer); | 287 webrtc_internals.RemoveObserver(&observer); |
| 234 } | 288 } |
| 235 | 289 |
| 236 TEST_F(WebRtcInternalsTest, SendAllUpdateWithGetUserMedia) { | 290 TEST_F(WebRtcInternalsTest, SendAllUpdateWithGetUserMedia) { |
| 237 const int rid = 1; | 291 const int rid = 1; |
| 238 const int pid = 2; | 292 const int pid = 2; |
| 239 const std::string audio_constraint = "aaa"; | 293 const std::string audio_constraint = "aaa"; |
| 240 const std::string video_constraint = "vvv"; | 294 const std::string video_constraint = "vvv"; |
| 241 WebRTCInternalsForTest webrtc_internals; | 295 WebRTCInternalsForTest webrtc_internals; |
| 242 webrtc_internals.OnGetUserMedia( | 296 webrtc_internals.OnGetUserMedia(rid, pid, kUrl, true, true, audio_constraint, |
| 243 rid, pid, kUrl, true, true, audio_constraint, video_constraint); | 297 video_constraint); |
| 244 | 298 |
| 245 MockWebRtcInternalsProxy observer; | 299 MockWebRtcInternalsProxy observer; |
| 246 // Add one observer after "getUserMedia". | 300 // Add one observer after "getUserMedia". |
| 247 webrtc_internals.AddObserver(&observer); | 301 webrtc_internals.AddObserver(&observer); |
| 248 webrtc_internals.UpdateObserver(&observer); | 302 webrtc_internals.UpdateObserver(&observer); |
| 249 | 303 |
| 250 EXPECT_EQ("addGetUserMedia", observer.command()); | 304 EXPECT_EQ("addGetUserMedia", observer.command()); |
| 251 VerifyGetUserMediaData( | 305 VerifyGetUserMediaData(observer.value(), rid, pid, kUrl, audio_constraint, |
| 252 observer.value(), rid, pid, kUrl, audio_constraint, video_constraint); | 306 video_constraint); |
| 253 | 307 |
| 254 webrtc_internals.RemoveObserver(&observer); | 308 webrtc_internals.RemoveObserver(&observer); |
| 255 } | 309 } |
| 256 | 310 |
| 257 TEST_F(WebRtcInternalsTest, SendAllUpdatesWithPeerConnectionUpdate) { | 311 TEST_F(WebRtcInternalsTest, SendAllUpdatesWithPeerConnectionUpdate) { |
| 258 const int rid = 0, pid = 1, lid = 2; | 312 const int rid = 0, pid = 1, lid = 2; |
| 259 const std::string update_type = "fakeType"; | 313 const std::string update_type = "fakeType"; |
| 260 const std::string update_value = "fakeValue"; | 314 const std::string update_value = "fakeValue"; |
| 261 | 315 |
| 262 WebRTCInternalsForTest webrtc_internals; | 316 WebRTCInternalsForTest webrtc_internals; |
| 263 | 317 |
| 264 webrtc_internals.OnAddPeerConnection( | |
| 265 rid, pid, lid, kUrl, kRtcConfiguration, kContraints); | |
| 266 webrtc_internals.OnUpdatePeerConnection( | |
| 267 pid, lid, update_type, update_value); | |
| 268 | |
| 269 MockWebRtcInternalsProxy observer; | 318 MockWebRtcInternalsProxy observer; |
| 270 webrtc_internals.AddObserver(&observer); | 319 webrtc_internals.AddObserver(&observer); |
| 271 | 320 |
| 321 webrtc_internals.OnAddPeerConnection(rid, pid, lid, kUrl, kRtcConfiguration, |
| 322 kContraints); |
| 323 webrtc_internals.OnUpdatePeerConnection(pid, lid, update_type, update_value); |
| 324 |
| 272 webrtc_internals.UpdateObserver(&observer); | 325 webrtc_internals.UpdateObserver(&observer); |
| 273 | 326 |
| 274 EXPECT_EQ("updateAllPeerConnections", observer.command()); | 327 EXPECT_EQ("updateAllPeerConnections", observer.command()); |
| 275 ASSERT_TRUE(observer.value()); | 328 ASSERT_TRUE(observer.value()); |
| 276 | 329 |
| 277 base::ListValue* list = NULL; | 330 base::ListValue* list = NULL; |
| 278 EXPECT_TRUE(observer.value()->GetAsList(&list)); | 331 EXPECT_TRUE(observer.value()->GetAsList(&list)); |
| 279 EXPECT_EQ(1U, list->GetSize()); | 332 EXPECT_EQ(1U, list->GetSize()); |
| 280 | 333 |
| 281 base::DictionaryValue* dict = NULL; | 334 base::DictionaryValue* dict = NULL; |
| 282 EXPECT_TRUE((*list->begin())->GetAsDictionary(&dict)); | 335 EXPECT_TRUE((*list->begin())->GetAsDictionary(&dict)); |
| 283 | 336 |
| 284 VerifyInt(dict, "rid", rid); | 337 VerifyInt(dict, "rid", rid); |
| 285 VerifyInt(dict, "pid", pid); | 338 VerifyInt(dict, "pid", pid); |
| 286 VerifyInt(dict, "lid", lid); | 339 VerifyInt(dict, "lid", lid); |
| 287 VerifyString(dict, "url", kUrl); | 340 VerifyString(dict, "url", kUrl); |
| 288 VerifyString(dict, "rtcConfiguration", kRtcConfiguration); | 341 VerifyString(dict, "rtcConfiguration", kRtcConfiguration); |
| 289 VerifyString(dict, "constraints", kContraints); | 342 VerifyString(dict, "constraints", kContraints); |
| 290 | 343 |
| 291 base::ListValue* log = NULL; | 344 base::ListValue* log = NULL; |
| 292 EXPECT_TRUE(dict->GetList("log", &log)); | 345 ASSERT_TRUE(dict->GetList("log", &log)); |
| 293 EXPECT_EQ(1U, log->GetSize()); | 346 EXPECT_EQ(1U, log->GetSize()); |
| 294 | 347 |
| 295 EXPECT_TRUE((*log->begin())->GetAsDictionary(&dict)); | 348 EXPECT_TRUE((*log->begin())->GetAsDictionary(&dict)); |
| 296 VerifyString(dict, "type", update_type); | 349 VerifyString(dict, "type", update_type); |
| 297 VerifyString(dict, "value", update_value); | 350 VerifyString(dict, "value", update_value); |
| 298 std::string time; | 351 std::string time; |
| 299 EXPECT_TRUE(dict->GetString("time", &time)); | 352 EXPECT_TRUE(dict->GetString("time", &time)); |
| 300 EXPECT_FALSE(time.empty()); | 353 EXPECT_FALSE(time.empty()); |
| 301 } | 354 } |
| 302 | 355 |
| 303 TEST_F(WebRtcInternalsTest, OnAddStats) { | 356 TEST_F(WebRtcInternalsTest, OnAddStats) { |
| 304 const int rid = 0, pid = 1, lid = 2; | 357 const int rid = 0, pid = 1, lid = 2; |
| 305 base::RunLoop loop; | 358 base::RunLoop loop; |
| 306 MockWebRtcInternalsProxy observer(&loop); | 359 MockWebRtcInternalsProxy observer(&loop); |
| 307 WebRTCInternalsForTest webrtc_internals; | 360 WebRTCInternalsForTest webrtc_internals; |
| 308 webrtc_internals.AddObserver(&observer); | 361 webrtc_internals.AddObserver(&observer); |
| 309 webrtc_internals.OnAddPeerConnection( | 362 webrtc_internals.OnAddPeerConnection(rid, pid, lid, kUrl, kRtcConfiguration, |
| 310 rid, pid, lid, kUrl, kRtcConfiguration, kContraints); | 363 kContraints); |
| 311 | 364 |
| 312 base::ListValue list; | 365 base::ListValue list; |
| 313 list.AppendString("xxx"); | 366 list.AppendString("xxx"); |
| 314 list.AppendString("yyy"); | 367 list.AppendString("yyy"); |
| 315 webrtc_internals.OnAddStats(pid, lid, list); | 368 webrtc_internals.OnAddStats(pid, lid, list); |
| 316 | 369 |
| 317 loop.Run(); | 370 loop.Run(); |
| 318 | 371 |
| 319 EXPECT_EQ("addStats", observer.command()); | 372 EXPECT_EQ("addStats", observer.command()); |
| 320 ASSERT_TRUE(observer.value()); | 373 ASSERT_TRUE(observer.value()); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 337 webrtc_internals.FileSelectionCanceled(nullptr); | 390 webrtc_internals.FileSelectionCanceled(nullptr); |
| 338 | 391 |
| 339 loop.Run(); | 392 loop.Run(); |
| 340 | 393 |
| 341 EXPECT_EQ("audioDebugRecordingsFileSelectionCancelled", observer.command()); | 394 EXPECT_EQ("audioDebugRecordingsFileSelectionCancelled", observer.command()); |
| 342 EXPECT_EQ(nullptr, observer.value()); | 395 EXPECT_EQ(nullptr, observer.value()); |
| 343 } | 396 } |
| 344 | 397 |
| 345 TEST_F(WebRtcInternalsTest, PowerSaveBlock) { | 398 TEST_F(WebRtcInternalsTest, PowerSaveBlock) { |
| 346 int kRenderProcessId = 1; | 399 int kRenderProcessId = 1; |
| 347 int pid = 1; | 400 const int pid = 1; |
| 348 int lid[] = {1, 2, 3}; | 401 const int lid[] = {1, 2, 3}; |
| 349 | 402 |
| 350 WebRTCInternalsForTest webrtc_internals; | 403 WebRTCInternalsForTest webrtc_internals; |
| 351 | 404 |
| 352 // Add a few peer connections. | 405 // Add a few peer connections. |
| 353 EXPECT_EQ(0, webrtc_internals.num_open_connections()); | 406 EXPECT_EQ(0, webrtc_internals.num_open_connections()); |
| 354 EXPECT_FALSE(webrtc_internals.IsPowerSavingBlocked()); | 407 EXPECT_FALSE(webrtc_internals.IsPowerSavingBlocked()); |
| 355 webrtc_internals.OnAddPeerConnection(kRenderProcessId, pid, lid[0], kUrl, | 408 webrtc_internals.OnAddPeerConnection(kRenderProcessId, pid, lid[0], kUrl, |
| 356 kRtcConfiguration, kContraints); | 409 kRtcConfiguration, kContraints); |
| 357 EXPECT_EQ(1, webrtc_internals.num_open_connections()); | 410 EXPECT_EQ(1, webrtc_internals.num_open_connections()); |
| 358 EXPECT_TRUE(webrtc_internals.IsPowerSavingBlocked()); | 411 EXPECT_TRUE(webrtc_internals.IsPowerSavingBlocked()); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 385 webrtc_internals.OnRemovePeerConnection(pid, lid[1]); | 438 webrtc_internals.OnRemovePeerConnection(pid, lid[1]); |
| 386 EXPECT_EQ(0, webrtc_internals.num_open_connections()); | 439 EXPECT_EQ(0, webrtc_internals.num_open_connections()); |
| 387 EXPECT_FALSE(webrtc_internals.IsPowerSavingBlocked()); | 440 EXPECT_FALSE(webrtc_internals.IsPowerSavingBlocked()); |
| 388 | 441 |
| 389 webrtc_internals.OnRemovePeerConnection(pid, lid[0]); | 442 webrtc_internals.OnRemovePeerConnection(pid, lid[0]); |
| 390 EXPECT_EQ(0, webrtc_internals.num_open_connections()); | 443 EXPECT_EQ(0, webrtc_internals.num_open_connections()); |
| 391 EXPECT_FALSE(webrtc_internals.IsPowerSavingBlocked()); | 444 EXPECT_FALSE(webrtc_internals.IsPowerSavingBlocked()); |
| 392 } | 445 } |
| 393 | 446 |
| 394 } // namespace content | 447 } // namespace content |
| OLD | NEW |