OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <memory> |
| 6 |
5 #include "base/command_line.h" | 7 #include "base/command_line.h" |
6 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
7 #include "content/browser/media/session/media_session.h" | 9 #include "content/browser/media/session/media_session.h" |
8 #include "content/browser/media/session/mock_media_session_observer.h" | 10 #include "content/browser/media/session/mock_media_session_observer.h" |
9 #include "content/public/test/content_browser_test.h" | 11 #include "content/public/test/content_browser_test.h" |
10 #include "content/shell/browser/shell.h" | 12 #include "content/shell/browser/shell.h" |
11 | 13 |
12 namespace content { | 14 namespace content { |
13 | 15 |
14 class MediaSessionDelegateAndroidBrowserTest : public ContentBrowserTest {}; | 16 class MediaSessionDelegateAndroidBrowserTest : public ContentBrowserTest {}; |
15 | 17 |
16 // MAYBE_OnAudioFocusChangeAfterDtorCrash will hit a DCHECK before the crash, it | 18 // MAYBE_OnAudioFocusChangeAfterDtorCrash will hit a DCHECK before the crash, it |
17 // is the only way found to actually reproduce the crash so as a result, the | 19 // is the only way found to actually reproduce the crash so as a result, the |
18 // test will only run on builds without DCHECK's. | 20 // test will only run on builds without DCHECK's. |
19 #if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON) | 21 #if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON) |
20 // TODO(crbug.com/602787) The test is flaky, disabling it everywhere. | 22 // TODO(crbug.com/602787) The test is flaky, disabling it everywhere. |
21 #define MAYBE_OnAudioFocusChangeAfterDtorCrash \ | 23 #define MAYBE_OnAudioFocusChangeAfterDtorCrash \ |
22 DISABLED_OnAudioFocusChangeAfterDtorCrash | 24 DISABLED_OnAudioFocusChangeAfterDtorCrash |
23 #else | 25 #else |
24 #define MAYBE_OnAudioFocusChangeAfterDtorCrash \ | 26 #define MAYBE_OnAudioFocusChangeAfterDtorCrash \ |
25 DISABLED_OnAudioFocusChangeAfterDtorCrash | 27 DISABLED_OnAudioFocusChangeAfterDtorCrash |
26 #endif | 28 #endif |
27 | 29 |
28 IN_PROC_BROWSER_TEST_F(MediaSessionDelegateAndroidBrowserTest, | 30 IN_PROC_BROWSER_TEST_F(MediaSessionDelegateAndroidBrowserTest, |
29 MAYBE_OnAudioFocusChangeAfterDtorCrash) { | 31 MAYBE_OnAudioFocusChangeAfterDtorCrash) { |
30 scoped_ptr<MockMediaSessionObserver> media_session_observer( | 32 std::unique_ptr<MockMediaSessionObserver> media_session_observer( |
31 new MockMediaSessionObserver); | 33 new MockMediaSessionObserver); |
32 | 34 |
33 MediaSession* media_session = MediaSession::Get(shell()->web_contents()); | 35 MediaSession* media_session = MediaSession::Get(shell()->web_contents()); |
34 ASSERT_TRUE(media_session); | 36 ASSERT_TRUE(media_session); |
35 | 37 |
36 WebContents* other_web_contents = CreateBrowser()->web_contents(); | 38 WebContents* other_web_contents = CreateBrowser()->web_contents(); |
37 MediaSession* other_media_session = MediaSession::Get(other_web_contents); | 39 MediaSession* other_media_session = MediaSession::Get(other_web_contents); |
38 ASSERT_TRUE(other_media_session); | 40 ASSERT_TRUE(other_media_session); |
39 | 41 |
40 media_session_observer->StartNewPlayer(); | 42 media_session_observer->StartNewPlayer(); |
(...skipping 14 matching lines...) Expand all Loading... |
55 // to the listeners. If the bug is still present, it will crash. | 57 // to the listeners. If the bug is still present, it will crash. |
56 { | 58 { |
57 base::RunLoop run_loop; | 59 base::RunLoop run_loop; |
58 base::MessageLoop::current()->PostDelayedTask( | 60 base::MessageLoop::current()->PostDelayedTask( |
59 FROM_HERE, run_loop.QuitClosure(), base::TimeDelta::FromSeconds(1)); | 61 FROM_HERE, run_loop.QuitClosure(), base::TimeDelta::FromSeconds(1)); |
60 run_loop.Run(); | 62 run_loop.Run(); |
61 } | 63 } |
62 } | 64 } |
63 | 65 |
64 } // namespace content | 66 } // namespace content |
OLD | NEW |