1 /*
2 * Copyright (c) 2025 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include <gtest/gtest.h>
17 #include "hpae_signal_process_thread.h"
18 #include "hpae_renderer_manager.h"
19
20 using namespace OHOS;
21 using namespace AudioStandard;
22 using namespace HPAE;
23 using namespace testing::ext;
24 using namespace testing;
25
26 class HpaeSignalProcessThreadTest : public testing::Test {
27 public:
28 void SetUp();
29 void TearDown();
30 };
31
SetUp()32 void HpaeSignalProcessThreadTest::SetUp()
33 {}
34
TearDown()35 void HpaeSignalProcessThreadTest::TearDown()
36 {}
37
38 HWTEST_F(HpaeSignalProcessThreadTest, ActivateDeactivateThread, TestSize.Level0)
39 {
40 std::shared_ptr<HpaeRendererManager> streamManager = nullptr;
41 std::unique_ptr<HpaeSignalProcessThread> hpaeSignalProcessThread = std::make_unique<HpaeSignalProcessThread>();
42 EXPECT_EQ(hpaeSignalProcessThread->IsRunning(), false);
43 EXPECT_EQ(hpaeSignalProcessThread->IsMsgProcessing(), false);
44
45 hpaeSignalProcessThread->ActivateThread(streamManager);
46 EXPECT_EQ(hpaeSignalProcessThread->IsRunning(), true);
47
48 hpaeSignalProcessThread->Notify();
49 EXPECT_EQ(hpaeSignalProcessThread->IsMsgProcessing(), true);
50
51 hpaeSignalProcessThread->DeactivateThread();
52 EXPECT_EQ(hpaeSignalProcessThread->IsRunning(), false);
53 }
54