| 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> | 5 #include <memory> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| 11 #include "base/threading/thread_task_runner_handle.h" | 11 #include "base/threading/thread_task_runner_handle.h" |
| 12 #include "content/browser/media/session/media_session.h" | 12 #include "content/browser/media/session/media_session.h" |
| 13 #include "content/browser/media/session/mock_media_session_observer.h" | 13 #include "content/browser/media/session/mock_media_session_observer.h" |
| 14 #include "content/public/test/content_browser_test.h" | 14 #include "content/public/test/content_browser_test.h" |
| 15 #include "content/shell/browser/shell.h" | 15 #include "content/shell/browser/shell.h" |
| 16 #include "media/base/media_content_type.h" |
| 16 | 17 |
| 17 namespace content { | 18 namespace content { |
| 18 | 19 |
| 19 class MediaSessionDelegateAndroidBrowserTest : public ContentBrowserTest {}; | 20 class MediaSessionDelegateAndroidBrowserTest : public ContentBrowserTest {}; |
| 20 | 21 |
| 21 // MAYBE_OnAudioFocusChangeAfterDtorCrash will hit a DCHECK before the crash, it | 22 // MAYBE_OnAudioFocusChangeAfterDtorCrash will hit a DCHECK before the crash, it |
| 22 // is the only way found to actually reproduce the crash so as a result, the | 23 // is the only way found to actually reproduce the crash so as a result, the |
| 23 // test will only run on builds without DCHECK's. | 24 // test will only run on builds without DCHECK's. |
| 24 #if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON) | 25 #if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON) |
| 25 // TODO(crbug.com/602787) The test is flaky, disabling it everywhere. | 26 // TODO(crbug.com/602787) The test is flaky, disabling it everywhere. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 37 | 38 |
| 38 MediaSession* media_session = MediaSession::Get(shell()->web_contents()); | 39 MediaSession* media_session = MediaSession::Get(shell()->web_contents()); |
| 39 ASSERT_TRUE(media_session); | 40 ASSERT_TRUE(media_session); |
| 40 | 41 |
| 41 WebContents* other_web_contents = CreateBrowser()->web_contents(); | 42 WebContents* other_web_contents = CreateBrowser()->web_contents(); |
| 42 MediaSession* other_media_session = MediaSession::Get(other_web_contents); | 43 MediaSession* other_media_session = MediaSession::Get(other_web_contents); |
| 43 ASSERT_TRUE(other_media_session); | 44 ASSERT_TRUE(other_media_session); |
| 44 | 45 |
| 45 media_session_observer->StartNewPlayer(); | 46 media_session_observer->StartNewPlayer(); |
| 46 media_session->AddPlayer(media_session_observer.get(), 0, | 47 media_session->AddPlayer(media_session_observer.get(), 0, |
| 47 MediaSession::Type::Content); | 48 media::MediaContentType::Persistent); |
| 48 EXPECT_TRUE(media_session->IsActive()); | 49 EXPECT_TRUE(media_session->IsActive()); |
| 49 EXPECT_FALSE(other_media_session->IsActive()); | 50 EXPECT_FALSE(other_media_session->IsActive()); |
| 50 | 51 |
| 51 media_session_observer->StartNewPlayer(); | 52 media_session_observer->StartNewPlayer(); |
| 52 other_media_session->AddPlayer(media_session_observer.get(), 1, | 53 other_media_session->AddPlayer(media_session_observer.get(), 1, |
| 53 MediaSession::Type::Content); | 54 media::MediaContentType::Persistent); |
| 54 EXPECT_TRUE(media_session->IsActive()); | 55 EXPECT_TRUE(media_session->IsActive()); |
| 55 EXPECT_TRUE(other_media_session->IsActive()); | 56 EXPECT_TRUE(other_media_session->IsActive()); |
| 56 | 57 |
| 57 shell()->CloseAllWindows(); | 58 shell()->CloseAllWindows(); |
| 58 | 59 |
| 59 // Give some time to the AudioFocusManager to send an audioFocusChange message | 60 // Give some time to the AudioFocusManager to send an audioFocusChange message |
| 60 // to the listeners. If the bug is still present, it will crash. | 61 // to the listeners. If the bug is still present, it will crash. |
| 61 { | 62 { |
| 62 base::RunLoop run_loop; | 63 base::RunLoop run_loop; |
| 63 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 64 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 64 FROM_HERE, run_loop.QuitClosure(), base::TimeDelta::FromSeconds(1)); | 65 FROM_HERE, run_loop.QuitClosure(), base::TimeDelta::FromSeconds(1)); |
| 65 run_loop.Run(); | 66 run_loop.Run(); |
| 66 } | 67 } |
| 67 } | 68 } |
| 68 | 69 |
| 69 } // namespace content | 70 } // namespace content |
| OLD | NEW |