forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdebug_recording_unittest.cc
81 lines (61 loc) · 2.47 KB
/
debug_recording_unittest.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "services/audio/debug_recording.h"
#include <memory>
#include "base/files/file_path.h"
#include "base/test/scoped_task_environment.h"
#include "media/audio/audio_debug_recording_test.h"
#include "media/audio/mock_audio_debug_recording_manager.h"
#include "media/audio/mock_audio_manager.h"
#include "services/audio/public/cpp/debug_recording_session.h"
#include "services/audio/public/mojom/debug_recording.mojom.h"
#include "testing/gmock/include/gmock/gmock.h"
namespace audio {
namespace {
const base::FilePath::CharType kBaseFileName[] =
FILE_PATH_LITERAL("base_file_name");
}
class DebugRecordingTest : public media::AudioDebugRecordingTest {
public:
DebugRecordingTest() = default;
~DebugRecordingTest() override = default;
void SetUp() override {
CreateAudioManager();
InitializeAudioDebugRecordingManager();
}
void TearDown() override { ShutdownAudioManager(); }
protected:
void CreateDebugRecording() {
debug_recording_ = std::make_unique<DebugRecording>(
mojo::MakeRequest(&debug_recording_ptr_),
static_cast<media::AudioManager*>(mock_audio_manager_.get()));
EXPECT_TRUE(debug_recording_ptr_.is_bound());
}
void EnableDebugRecording() {
mojom::DebugRecordingFileProviderPtr file_provider_ptr;
DebugRecordingSession::DebugRecordingFileProvider file_provider(
mojo::MakeRequest(&file_provider_ptr), base::FilePath(kBaseFileName));
ASSERT_TRUE(file_provider_ptr.is_bound());
debug_recording_ptr_->Enable(std::move(file_provider_ptr));
}
void DestroyDebugRecording() { debug_recording_ptr_.reset(); }
MOCK_METHOD0(OnConnectionError, void());
private:
std::unique_ptr<DebugRecording> debug_recording_;
mojom::DebugRecordingPtr debug_recording_ptr_;
DISALLOW_COPY_AND_ASSIGN(DebugRecordingTest);
};
TEST_F(DebugRecordingTest, EnableResetEnablesDisablesDebugRecording) {
CreateDebugRecording();
EXPECT_CALL(*mock_debug_recording_manager_, EnableDebugRecording(testing::_));
EnableDebugRecording();
EXPECT_CALL(*mock_debug_recording_manager_, DisableDebugRecording());
DestroyDebugRecording();
}
TEST_F(DebugRecordingTest, ResetWithoutEnableDoesNotDisableDebugRecording) {
CreateDebugRecording();
EXPECT_CALL(*mock_debug_recording_manager_, DisableDebugRecording()).Times(0);
DestroyDebugRecording();
}
} // namespace audio