1 /*
2 * Copyright (c) 2022 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 "audio_transport_context_test.h"
17
18 #include "daudio_errorcode.h"
19 #include "daudio_log.h"
20 #include "daudio_util.h"
21
22 using namespace testing::ext;
23
24 namespace OHOS {
25 namespace DistributedHardware {
SetUpTestCase(void)26 void AudioTransportContextTest::SetUpTestCase(void) {}
27
TearDownTestCase(void)28 void AudioTransportContextTest::TearDownTestCase(void) {}
29
SetUp(void)30 void AudioTransportContextTest::SetUp(void)
31 {
32 stateContext_ = std::make_shared<AudioTransportContext>();
33 }
34
TearDown(void)35 void AudioTransportContextTest::TearDown(void)
36 {
37 stateContext_ = nullptr;
38 }
39
40 /**
41 * @tc.name: GetTransportStatus_001
42 * @tc.desc: Verify GetTransportStatus func.
43 * @tc.type: FUNC
44 * @tc.require: AR000H0E5U
45 */
46 HWTEST_F(AudioTransportContextTest, GetTransportStatus_001, TestSize.Level1)
47 {
48 TransportStateType type = TransportStateType::TRANSPORT_STATE_START;
49 EXPECT_EQ(ERR_DH_AUDIO_NULLPTR, stateContext_->GetTransportStatusType());
50 stateContext_->SetTransportStatus(type);
51 EXPECT_EQ(TransportStateType::TRANSPORT_STATE_START, stateContext_->GetTransportStatusType());
52 }
53
54 /**
55 * @tc.name: Stop_001
56 * @tc.desc: Verify Stop func.
57 * @tc.type: FUNC
58 * @tc.require: AR000H0E5U
59 */
60 HWTEST_F(AudioTransportContextTest, Stop_001, TestSize.Level1)
61 {
62 EXPECT_EQ(ERR_DH_AUDIO_NULLPTR, stateContext_->Start());
63 EXPECT_EQ(ERR_DH_AUDIO_NULLPTR, stateContext_->Pause());
64 EXPECT_EQ(ERR_DH_AUDIO_NULLPTR, stateContext_->Stop());
65 TransportStateType type = TransportStateType::TRANSPORT_STATE_START;
66 stateContext_->SetTransportStatus(type);
67 EXPECT_EQ(DH_SUCCESS, stateContext_->Start());
68 EXPECT_NE(DH_SUCCESS, stateContext_->Stop());
69 }
70 } // namespace DistributedHardware
71 } // namespace OHOS
72