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

Side by Side Diff: content/browser/renderer_host/media/audio_renderer_host_unittest.cc

Issue 2869733005: Convert some audio code to OnceCallback. (Closed)
Patch Set: Rebase, comments on unretained. Created 3 years, 7 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 (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 "content/browser/renderer_host/media/audio_renderer_host.h" 5 #include "content/browser/renderer_host/media/audio_renderer_host.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 const char kDefaultDeviceId[] = ""; 51 const char kDefaultDeviceId[] = "";
52 const char kSalt[] = "salt"; 52 const char kSalt[] = "salt";
53 const char kNondefaultDeviceId[] = 53 const char kNondefaultDeviceId[] =
54 "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef"; 54 "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef";
55 const char kBadDeviceId[] = 55 const char kBadDeviceId[] =
56 "badbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbad1"; 56 "badbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbad1";
57 const char kInvalidDeviceId[] = "invalid-device-id"; 57 const char kInvalidDeviceId[] = "invalid-device-id";
58 58
59 void ValidateRenderFrameId(int render_process_id, 59 void ValidateRenderFrameId(int render_process_id,
60 int render_frame_id, 60 int render_frame_id,
61 const base::Callback<void(bool)>& callback) { 61 base::OnceCallback<void(bool)> callback) {
62 DCHECK_CURRENTLY_ON(BrowserThread::UI); 62 DCHECK_CURRENTLY_ON(BrowserThread::UI);
63 const bool frame_exists = (render_frame_id == kRenderFrameId); 63 const bool frame_exists = (render_frame_id == kRenderFrameId);
64 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, 64 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
65 base::Bind(callback, frame_exists)); 65 base::BindOnce(std::move(callback), frame_exists));
66 } 66 }
67 67
68 68
69 class MockAudioMirroringManager : public AudioMirroringManager { 69 class MockAudioMirroringManager : public AudioMirroringManager {
70 public: 70 public:
71 MockAudioMirroringManager() {} 71 MockAudioMirroringManager() {}
72 virtual ~MockAudioMirroringManager() {} 72 virtual ~MockAudioMirroringManager() {}
73 73
74 MOCK_METHOD3(AddDiverter, 74 MOCK_METHOD3(AddDiverter,
75 void(int render_process_id, 75 void(int render_process_id,
(...skipping 15 matching lines...) Expand all
91 MockRenderProcessHost::ShutdownForBadMessage(crash_report_mode); 91 MockRenderProcessHost::ShutdownForBadMessage(crash_report_mode);
92 auth_run_loop_->Quit(); 92 auth_run_loop_->Quit();
93 } 93 }
94 94
95 private: 95 private:
96 base::RunLoop* auth_run_loop_; 96 base::RunLoop* auth_run_loop_;
97 }; 97 };
98 98
99 class FakeAudioManagerWithAssociations : public media::FakeAudioManager { 99 class FakeAudioManagerWithAssociations : public media::FakeAudioManager {
100 public: 100 public:
101 FakeAudioManagerWithAssociations(media::AudioLogFactory* factory) 101 explicit FakeAudioManagerWithAssociations(media::AudioLogFactory* factory)
102 : FakeAudioManager(base::MakeUnique<media::TestAudioThread>(), factory) {} 102 : FakeAudioManager(base::MakeUnique<media::TestAudioThread>(), factory) {}
103 103
104 void CreateDeviceAssociation(const std::string& input_device_id, 104 void CreateDeviceAssociation(const std::string& input_device_id,
105 const std::string& output_device_id) { 105 const std::string& output_device_id) {
106 // We shouldn't accidentally add hashed ids, since the audio manager 106 // We shouldn't accidentally add hashed ids, since the audio manager
107 // works with raw ids. 107 // works with raw ids.
108 EXPECT_FALSE(IsValidDeviceId(input_device_id)); 108 EXPECT_FALSE(IsValidDeviceId(input_device_id));
109 EXPECT_FALSE(IsValidDeviceId(output_device_id)); 109 EXPECT_FALSE(IsValidDeviceId(output_device_id));
110 110
111 associations_[input_device_id] = output_device_id; 111 associations_[input_device_id] = output_device_id;
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 } 617 }
618 618
619 TEST_F(AudioRendererHostTest, CreateFailsForInvalidRenderFrame) { 619 TEST_F(AudioRendererHostTest, CreateFailsForInvalidRenderFrame) {
620 CreateWithInvalidRenderFrameId(); 620 CreateWithInvalidRenderFrameId();
621 Close(); 621 Close();
622 } 622 }
623 623
624 // TODO(hclam): Add tests for data conversation in low latency mode. 624 // TODO(hclam): Add tests for data conversation in low latency mode.
625 625
626 } // namespace content 626 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698