• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2023 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 "./distributedaudiotest.h"
18 
19 using namespace testing::ext;
20 using namespace OHOS::DistributedHardware;
21 
22 int32_t g_audioOk = 0;
23 int32_t g_audioDelay = 5;
24 std::string res = "true";
25 
26 class DAudioAutomatTest : public testing::Test {
27 public:
28     static void SetUpTestCase(void);
29     static void TearDownTestCase(void);
30     void SetUp();
31     void TearDown();
32     DAudioAutomatTest();
33 };
SetUpTestCase(void)34 void DAudioAutomatTest::SetUpTestCase(void){
35     int ret = InitTestDemo();
36     if (ret != g_audioOk) {
37         DHLOGI("demo test:InitTestDemo error");
38         return;
39     }
40 }
TearDownTestCase(void)41 void DAudioAutomatTest::TearDownTestCase(void) {}
SetUp(void)42 void DAudioAutomatTest::SetUp(void) {}
TearDown(void)43 void DAudioAutomatTest::TearDown(void) {}
DAudioAutomatTest(void)44 DAudioAutomatTest::DAudioAutomatTest(void) {}
45 
46 HWTEST_F(DAudioAutomatTest, SUB_DH_DAudio_Dcts_0001, TestSize.Level1)
47 {
48     std::string ret = FindAudioDevice();
49     EXPECT_EQ(res, ret) << "FindAudioDevice fail";
50     sleep(g_audioDelay);
51 }
52 
53 HWTEST_F(DAudioAutomatTest, SUB_DH_DAudio_Dcts_0002, TestSize.Level1)
54 {
55     std::string ret = OpenSpk();
56     EXPECT_EQ(res, ret) << "OpenSpk fail";
57     sleep(g_audioDelay);
58 }
59 
60 HWTEST_F(DAudioAutomatTest, SUB_DH_DAudio_Dcts_0003, TestSize.Level1)
61 {
62     std::string ret = StartRender();
63     EXPECT_EQ(res, ret) << "StartRender fail";
64     sleep(g_audioDelay);
65 }
66 
67 HWTEST_F(DAudioAutomatTest, SUB_DH_DAudio_Dcts_0004, TestSize.Level1)
68 {
69     std::string ret = StopRender();
70     EXPECT_EQ(res, ret) << "StopRender fail";
71     sleep(g_audioDelay);
72 }
73 
74 HWTEST_F(DAudioAutomatTest, SUB_DH_DAudio_Dcts_0005, TestSize.Level1)
75 {
76     std::string ret = CloseSpk();
77     EXPECT_EQ(res, ret) << "CloseSpk fail";
78     sleep(g_audioDelay);
79 }
80 
81 HWTEST_F(DAudioAutomatTest, SUB_DH_DAudio_Dcts_0006, TestSize.Level1)
82 {
83     std::string ret = OpenMic();
84     EXPECT_EQ(res, ret) << "OpenMic fail";
85     sleep(g_audioDelay);
86 }
87 
88 HWTEST_F(DAudioAutomatTest, SUB_DH_DAudio_Dcts_0007, TestSize.Level1)
89 {
90     std::string ret = StartCapture();
91     EXPECT_EQ(res, ret) << "StartCapture fail";
92     sleep(g_audioDelay);
93 }
94 
95 HWTEST_F(DAudioAutomatTest, SUB_DH_DAudio_Dcts_0008, TestSize.Level1)
96 {
97     std::string ret = StopCapture();
98     EXPECT_EQ(res, ret) << "StopCapture fail";
99     sleep(g_audioDelay);
100 }
101 
102 HWTEST_F(DAudioAutomatTest, SUB_DH_DAudio_Dcts_0009, TestSize.Level1)
103 {
104     std::string ret = CloseMic();
105     EXPECT_EQ(res, ret) << "CloseMic fail";
106     sleep(g_audioDelay);
107 }
108 
109 HWTEST_F(DAudioAutomatTest, SUB_DH_DAudio_Dcts_0010, TestSize.Level1)
110 {
111     std::string ret = SetVolume("5");
112     EXPECT_EQ(res, ret) << "SetVolume five fail";
113     sleep(g_audioDelay);
114     ret = SetVolume("1");
115     EXPECT_EQ(res, ret) << "SetVolume one fail";
116     sleep(g_audioDelay);
117 }
118 
119 HWTEST_F(DAudioAutomatTest, SUB_DH_DAudio_Dcts_0011, TestSize.Level1)
120 {
121     std::string ret = GetVolume();
122     EXPECT_EQ(res, ret) << "GetVolume fail";
123     sleep(g_audioDelay);
124 }