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" |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 | 388 |
389 webrtc_internals.AddObserver(&observer); | 389 webrtc_internals.AddObserver(&observer); |
390 webrtc_internals.FileSelectionCanceled(nullptr); | 390 webrtc_internals.FileSelectionCanceled(nullptr); |
391 | 391 |
392 loop.Run(); | 392 loop.Run(); |
393 | 393 |
394 EXPECT_EQ("audioDebugRecordingsFileSelectionCancelled", observer.command()); | 394 EXPECT_EQ("audioDebugRecordingsFileSelectionCancelled", observer.command()); |
395 EXPECT_EQ(nullptr, observer.value()); | 395 EXPECT_EQ(nullptr, observer.value()); |
396 } | 396 } |
397 | 397 |
398 TEST_F(WebRtcInternalsTest, PowerSaveBlock) { | 398 TEST_F(WebRtcInternalsTest, WakeLock) { |
399 int kRenderProcessId = 1; | 399 int kRenderProcessId = 1; |
400 const int pid = 1; | 400 const int pid = 1; |
401 const int lid[] = {1, 2, 3}; | 401 const int lid[] = {1, 2, 3}; |
402 | 402 |
403 WebRTCInternalsForTest webrtc_internals; | 403 WebRTCInternalsForTest webrtc_internals; |
404 | 404 |
405 // Add a few peer connections. | 405 // Add a few peer connections. |
406 EXPECT_EQ(0, webrtc_internals.num_open_connections()); | 406 EXPECT_EQ(0, webrtc_internals.num_open_connections()); |
407 EXPECT_FALSE(webrtc_internals.IsPowerSavingBlocked()); | 407 EXPECT_FALSE(webrtc_internals.HasWakeLockForTesting()); |
408 webrtc_internals.OnAddPeerConnection(kRenderProcessId, pid, lid[0], kUrl, | 408 webrtc_internals.OnAddPeerConnection(kRenderProcessId, pid, lid[0], kUrl, |
409 kRtcConfiguration, kContraints); | 409 kRtcConfiguration, kContraints); |
410 EXPECT_EQ(1, webrtc_internals.num_open_connections()); | 410 EXPECT_EQ(1, webrtc_internals.num_open_connections()); |
411 EXPECT_TRUE(webrtc_internals.IsPowerSavingBlocked()); | 411 EXPECT_TRUE(webrtc_internals.HasWakeLockForTesting()); |
412 | 412 |
413 webrtc_internals.OnAddPeerConnection(kRenderProcessId, pid, lid[1], kUrl, | 413 webrtc_internals.OnAddPeerConnection(kRenderProcessId, pid, lid[1], kUrl, |
414 kRtcConfiguration, kContraints); | 414 kRtcConfiguration, kContraints); |
415 EXPECT_EQ(2, webrtc_internals.num_open_connections()); | 415 EXPECT_EQ(2, webrtc_internals.num_open_connections()); |
416 EXPECT_TRUE(webrtc_internals.IsPowerSavingBlocked()); | 416 EXPECT_TRUE(webrtc_internals.HasWakeLockForTesting()); |
417 | 417 |
418 webrtc_internals.OnAddPeerConnection(kRenderProcessId, pid, lid[2], kUrl, | 418 webrtc_internals.OnAddPeerConnection(kRenderProcessId, pid, lid[2], kUrl, |
419 kRtcConfiguration, kContraints); | 419 kRtcConfiguration, kContraints); |
420 EXPECT_EQ(3, webrtc_internals.num_open_connections()); | 420 EXPECT_EQ(3, webrtc_internals.num_open_connections()); |
421 EXPECT_TRUE(webrtc_internals.IsPowerSavingBlocked()); | 421 EXPECT_TRUE(webrtc_internals.HasWakeLockForTesting()); |
422 | 422 |
423 // Remove a peer connection without closing it first. | 423 // Remove a peer connection without closing it first. |
424 webrtc_internals.OnRemovePeerConnection(pid, lid[2]); | 424 webrtc_internals.OnRemovePeerConnection(pid, lid[2]); |
425 EXPECT_EQ(2, webrtc_internals.num_open_connections()); | 425 EXPECT_EQ(2, webrtc_internals.num_open_connections()); |
426 EXPECT_TRUE(webrtc_internals.IsPowerSavingBlocked()); | 426 EXPECT_TRUE(webrtc_internals.HasWakeLockForTesting()); |
427 | 427 |
428 // Close the remaining peer connections. | 428 // Close the remaining peer connections. |
429 webrtc_internals.OnUpdatePeerConnection(pid, lid[1], "stop", std::string()); | 429 webrtc_internals.OnUpdatePeerConnection(pid, lid[1], "stop", std::string()); |
430 EXPECT_EQ(1, webrtc_internals.num_open_connections()); | 430 EXPECT_EQ(1, webrtc_internals.num_open_connections()); |
431 EXPECT_TRUE(webrtc_internals.IsPowerSavingBlocked()); | 431 EXPECT_TRUE(webrtc_internals.HasWakeLockForTesting()); |
432 | 432 |
433 webrtc_internals.OnUpdatePeerConnection(pid, lid[0], "stop", std::string()); | 433 webrtc_internals.OnUpdatePeerConnection(pid, lid[0], "stop", std::string()); |
434 EXPECT_EQ(0, webrtc_internals.num_open_connections()); | 434 EXPECT_EQ(0, webrtc_internals.num_open_connections()); |
435 EXPECT_FALSE(webrtc_internals.IsPowerSavingBlocked()); | 435 EXPECT_FALSE(webrtc_internals.HasWakeLockForTesting()); |
436 | 436 |
437 // Remove the remaining peer connections. | 437 // Remove the remaining peer connections. |
438 webrtc_internals.OnRemovePeerConnection(pid, lid[1]); | 438 webrtc_internals.OnRemovePeerConnection(pid, lid[1]); |
439 EXPECT_EQ(0, webrtc_internals.num_open_connections()); | 439 EXPECT_EQ(0, webrtc_internals.num_open_connections()); |
440 EXPECT_FALSE(webrtc_internals.IsPowerSavingBlocked()); | 440 EXPECT_FALSE(webrtc_internals.HasWakeLockForTesting()); |
441 | 441 |
442 webrtc_internals.OnRemovePeerConnection(pid, lid[0]); | 442 webrtc_internals.OnRemovePeerConnection(pid, lid[0]); |
443 EXPECT_EQ(0, webrtc_internals.num_open_connections()); | 443 EXPECT_EQ(0, webrtc_internals.num_open_connections()); |
444 EXPECT_FALSE(webrtc_internals.IsPowerSavingBlocked()); | 444 EXPECT_FALSE(webrtc_internals.HasWakeLockForTesting()); |
445 } | 445 } |
446 | 446 |
447 } // namespace content | 447 } // namespace content |
OLD | NEW |