| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/macros.h" | 6 #include "base/macros.h" |
| 7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
| 8 #include "base/process/process.h" | 8 #include "base/process/process.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/test/test_timeouts.h" | 10 #include "base/test/test_timeouts.h" |
| (...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 base::Process no_audio_process_; | 586 base::Process no_audio_process_; |
| 587 | 587 |
| 588 content::WebContents* audio_tab_web_contents_; | 588 content::WebContents* audio_tab_web_contents_; |
| 589 | 589 |
| 590 private: | 590 private: |
| 591 DISALLOW_COPY_AND_ASSIGN(ChromeRenderProcessHostBackgroundingTest); | 591 DISALLOW_COPY_AND_ASSIGN(ChromeRenderProcessHostBackgroundingTest); |
| 592 }; | 592 }; |
| 593 | 593 |
| 594 // Test to make sure that a process is backgrounded when the audio stops playing | 594 // Test to make sure that a process is backgrounded when the audio stops playing |
| 595 // from the active tab and there is an immediate tab switch. | 595 // from the active tab and there is an immediate tab switch. |
| 596 // Disable on Windows due to ongoing flakiness. (crbug.com/616421) | |
| 597 #if defined(OS_WIN) | |
| 598 #define MAYBE_ProcessPriorityAfterStoppedAudio \ | |
| 599 DISABLED_ProcessPriorityAfterStoppedAudio | |
| 600 #else | |
| 601 #define MAYBE_ProcessPriorityAfterStoppedAudio ProcessPriorityAfterStoppedAudio | |
| 602 #endif | |
| 603 IN_PROC_BROWSER_TEST_F(ChromeRenderProcessHostBackgroundingTest, | 596 IN_PROC_BROWSER_TEST_F(ChromeRenderProcessHostBackgroundingTest, |
| 604 MAYBE_ProcessPriorityAfterStoppedAudio) { | 597 ProcessPriorityAfterStoppedAudio) { |
| 605 // This test is invalid on platforms that can't background. | 598 // This test is invalid on platforms that can't background. |
| 606 if (!base::Process::CanBackgroundProcesses()) | 599 if (!base::Process::CanBackgroundProcesses()) |
| 607 return; | 600 return; |
| 608 | 601 |
| 609 ShowSingletonTab(audio_url_); | 602 ShowSingletonTab(audio_url_); |
| 610 | 603 |
| 611 // Wait until the no audio page is backgrounded and the audio page is not | 604 // Wait until the no audio page is backgrounded and the audio page is not |
| 612 // backgrounded. | 605 // backgrounded. |
| 613 while (!no_audio_process_.IsProcessBackgrounded() || | 606 while (!no_audio_process_.IsProcessBackgrounded() || |
| 614 audio_process_.IsProcessBackgrounded()) { | 607 audio_process_.IsProcessBackgrounded()) { |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 686 content::ExecuteScript(audio_tab_web_contents_, | 679 content::ExecuteScript(audio_tab_web_contents_, |
| 687 "document.getElementById('audioPlayer').play();")); | 680 "document.getElementById('audioPlayer').play();")); |
| 688 | 681 |
| 689 // Wait until the two pages are not backgrounded. | 682 // Wait until the two pages are not backgrounded. |
| 690 while (no_audio_process_.IsProcessBackgrounded() || | 683 while (no_audio_process_.IsProcessBackgrounded() || |
| 691 audio_process_.IsProcessBackgrounded()) { | 684 audio_process_.IsProcessBackgrounded()) { |
| 692 base::RunLoop().RunUntilIdle(); | 685 base::RunLoop().RunUntilIdle(); |
| 693 base::PlatformThread::Sleep(TestTimeouts::tiny_timeout()); | 686 base::PlatformThread::Sleep(TestTimeouts::tiny_timeout()); |
| 694 } | 687 } |
| 695 } | 688 } |
| OLD | NEW |