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