Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Side by Side Diff: content/browser/media/session/audio_focus_delegate_android_browsertest.cc

Issue 2416853005: Fixing naming issues in MediaSession (Closed)
Patch Set: addressed nits Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_player_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 #include "media/base/media_content_type.h"
17 17
18 namespace content { 18 namespace content {
19 19
20 class MediaSessionDelegateAndroidBrowserTest : public ContentBrowserTest {}; 20 class AudioFocusDelegateAndroidBrowserTest : public ContentBrowserTest {};
21 21
22 // MAYBE_OnAudioFocusChangeAfterDtorCrash will hit a DCHECK before the crash, it 22 // MAYBE_OnAudioFocusChangeAfterDtorCrash will hit a DCHECK before the crash, it
23 // 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
24 // test will only run on builds without DCHECK's. 24 // test will only run on builds without DCHECK's.
25 #if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON) 25 #if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON)
26 // TODO(crbug.com/602787) The test is flaky, disabling it everywhere. 26 // TODO(crbug.com/602787) The test is flaky, disabling it everywhere.
27 #define MAYBE_OnAudioFocusChangeAfterDtorCrash \ 27 #define MAYBE_OnAudioFocusChangeAfterDtorCrash \
28 DISABLED_OnAudioFocusChangeAfterDtorCrash 28 DISABLED_OnAudioFocusChangeAfterDtorCrash
29 #else 29 #else
30 #define MAYBE_OnAudioFocusChangeAfterDtorCrash \ 30 #define MAYBE_OnAudioFocusChangeAfterDtorCrash \
31 DISABLED_OnAudioFocusChangeAfterDtorCrash 31 DISABLED_OnAudioFocusChangeAfterDtorCrash
32 #endif 32 #endif
33 33
34 IN_PROC_BROWSER_TEST_F(MediaSessionDelegateAndroidBrowserTest, 34 IN_PROC_BROWSER_TEST_F(AudioFocusDelegateAndroidBrowserTest,
35 MAYBE_OnAudioFocusChangeAfterDtorCrash) { 35 MAYBE_OnAudioFocusChangeAfterDtorCrash) {
36 std::unique_ptr<MockMediaSessionObserver> media_session_observer( 36 std::unique_ptr<MockMediaSessionPlayerObserver> player_observer(
37 new MockMediaSessionObserver); 37 new MockMediaSessionPlayerObserver);
38 38
39 MediaSession* media_session = MediaSession::Get(shell()->web_contents()); 39 MediaSession* media_session = MediaSession::Get(shell()->web_contents());
40 ASSERT_TRUE(media_session); 40 ASSERT_TRUE(media_session);
41 41
42 WebContents* other_web_contents = CreateBrowser()->web_contents(); 42 WebContents* other_web_contents = CreateBrowser()->web_contents();
43 MediaSession* other_media_session = MediaSession::Get(other_web_contents); 43 MediaSession* other_media_session = MediaSession::Get(other_web_contents);
44 ASSERT_TRUE(other_media_session); 44 ASSERT_TRUE(other_media_session);
45 45
46 media_session_observer->StartNewPlayer(); 46 player_observer->StartNewPlayer();
47 media_session->AddPlayer(media_session_observer.get(), 0, 47 media_session->AddPlayer(player_observer.get(), 0,
48 media::MediaContentType::Persistent); 48 media::MediaContentType::Persistent);
49 EXPECT_TRUE(media_session->IsActive()); 49 EXPECT_TRUE(media_session->IsActive());
50 EXPECT_FALSE(other_media_session->IsActive()); 50 EXPECT_FALSE(other_media_session->IsActive());
51 51
52 media_session_observer->StartNewPlayer(); 52 player_observer->StartNewPlayer();
53 other_media_session->AddPlayer(media_session_observer.get(), 1, 53 other_media_session->AddPlayer(player_observer.get(), 1,
54 media::MediaContentType::Persistent); 54 media::MediaContentType::Persistent);
55 EXPECT_TRUE(media_session->IsActive()); 55 EXPECT_TRUE(media_session->IsActive());
56 EXPECT_TRUE(other_media_session->IsActive()); 56 EXPECT_TRUE(other_media_session->IsActive());
57 57
58 shell()->CloseAllWindows(); 58 shell()->CloseAllWindows();
59 59
60 // Give some time to the AudioFocusManager to send an audioFocusChange message 60 // Give some time to the AudioFocusManager to send an audioFocusChange message
61 // 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.
62 { 62 {
63 base::RunLoop run_loop; 63 base::RunLoop run_loop;
64 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 64 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
65 FROM_HERE, run_loop.QuitClosure(), base::TimeDelta::FromSeconds(1)); 65 FROM_HERE, run_loop.QuitClosure(), base::TimeDelta::FromSeconds(1));
66 run_loop.Run(); 66 run_loop.Run();
67 } 67 }
68 } 68 }
69 69
70 } // namespace content 70 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698