• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <gtest/gtest.h>
17 #include "soc_perf_client_adapter_impl.h"
18 
19 using namespace testing;
20 using namespace testing::ext;
21 using namespace OHOS;
22 using namespace OHOS::NWeb;
23 
24 namespace OHOS::NWeb {
25 namespace {
26     const uint32_t SOC_PERF_ID = UINT32_MAX;
27 }
28 
29 class SocPerfAdapterTest : public testing::Test {
30 public:
31     static void SetUpTestCase(void);
32     static void TearDownTestCase(void);
33     void SetUp();
34     void TearDown();
35 };
36 
SetUpTestCase(void)37 void SocPerfAdapterTest::SetUpTestCase(void)
38 {}
39 
TearDownTestCase(void)40 void SocPerfAdapterTest::TearDownTestCase(void)
41 {}
42 
SetUp(void)43 void SocPerfAdapterTest::SetUp(void)
44 {}
45 
TearDown(void)46 void SocPerfAdapterTest::TearDown(void)
47 {}
48 
49 /**
50  * @tc.name: SocPerfAdapterTest_001.
51  * @tc.desc: test apply socperf config
52  * @tc.type: FUNC
53  * @tc.require:
54  */
55 HWTEST_F(SocPerfAdapterTest, SocPerfAdapterTest_001, TestSize.Level1)
56 {
57     std::unique_ptr<SocPerfClientAdapterImpl> socPerfClient = std::make_unique<SocPerfClientAdapterImpl>();
58     EXPECT_NE(socPerfClient, nullptr);
59     const int SOC_PERF_CONFIG_ID = 10020;
60     socPerfClient->ApplySocPerfConfigById(SOC_PERF_CONFIG_ID);
61     socPerfClient->ApplySocPerfConfigById(0);
62     socPerfClient->ApplySocPerfConfigByIdEx(SOC_PERF_CONFIG_ID, true);
63     socPerfClient->ApplySocPerfConfigByIdEx(0, true);
64 
65     int SOC_PERF_ID = 10012;
66     socPerfClient->ApplySocPerfConfigById(SOC_PERF_ID);
67     socPerfClient->ApplySocPerfConfigByIdEx(SOC_PERF_ID, true);
68     socPerfClient->ApplySocPerfConfigByIdEx(SOC_PERF_ID, false);
69 
70     SOC_PERF_ID = 10020;
71     socPerfClient->ApplySocPerfConfigById(SOC_PERF_ID);
72     socPerfClient->ApplySocPerfConfigByIdEx(SOC_PERF_ID, true);
73     socPerfClient->ApplySocPerfConfigByIdEx(SOC_PERF_ID, false);
74 
75     SOC_PERF_ID = 10025;
76     socPerfClient->ApplySocPerfConfigById(SOC_PERF_ID);
77     socPerfClient->ApplySocPerfConfigByIdEx(SOC_PERF_ID, true);
78     socPerfClient->ApplySocPerfConfigByIdEx(SOC_PERF_ID, false);
79 
80     SOC_PERF_ID = 10070;
81     socPerfClient->ApplySocPerfConfigById(SOC_PERF_ID);
82     socPerfClient->ApplySocPerfConfigByIdEx(SOC_PERF_ID, true);
83     socPerfClient->ApplySocPerfConfigByIdEx(SOC_PERF_ID, false);
84 
85     SOC_PERF_ID = 10071;
86     socPerfClient->ApplySocPerfConfigById(SOC_PERF_ID);
87     socPerfClient->ApplySocPerfConfigByIdEx(SOC_PERF_ID, true);
88     socPerfClient->ApplySocPerfConfigByIdEx(SOC_PERF_ID, false);
89 
90     SOC_PERF_ID = 10073;
91     socPerfClient->ApplySocPerfConfigById(SOC_PERF_ID);
92     socPerfClient->ApplySocPerfConfigByIdEx(SOC_PERF_ID, true);
93     socPerfClient->ApplySocPerfConfigByIdEx(SOC_PERF_ID, false);
94 
95     SOC_PERF_ID = 10097;
96     socPerfClient->ApplySocPerfConfigById(SOC_PERF_ID);
97     socPerfClient->ApplySocPerfConfigByIdEx(SOC_PERF_ID, true);
98     socPerfClient->ApplySocPerfConfigByIdEx(SOC_PERF_ID, false);
99 }
100 
101 /**
102  * @tc.name: SocPerfAdapterTest_002.
103  * @tc.desc: test apply socperf ConfigById
104  * @tc.type: FUNC
105  * @tc.require:
106  */
107 HWTEST_F(SocPerfAdapterTest, SocPerfAdapterTest_002, TestSize.Level1)
108 {
109     auto  socPerfClient = std::make_shared<SocPerfClientAdapterImpl>();
110     EXPECT_NE(socPerfClient, nullptr);
111     socPerfClient->ApplySocPerfConfigById(SOC_PERF_ID);
112     socPerfClient->ApplySocPerfConfigById(0);
113 }
114 
115 /**
116  * @tc.name: SocPerfAdapterTest_003.
117  * @tc.desc: test apply socperf ConfigByIdEx
118  * @tc.type: FUNC
119  * @tc.require:
120  */
121 HWTEST_F(SocPerfAdapterTest, SocPerfAdapterTest_003, TestSize.Level1)
122 {
123     auto  socPerfClient = std::make_shared<SocPerfClientAdapterImpl>();
124     EXPECT_NE(socPerfClient, nullptr);
125     socPerfClient->ApplySocPerfConfigByIdEx(SOC_PERF_ID, true);
126     socPerfClient->ApplySocPerfConfigByIdEx(SOC_PERF_ID, false);
127     socPerfClient->ApplySocPerfConfigByIdEx(0, true);
128     socPerfClient->ApplySocPerfConfigByIdEx(0, false);
129 }
130 } // namespace NWeb
131