1 /* 2 * Copyright (c) 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 "iplugin_manager.h" 18 #include "plugin_singleton.h" 19 #include "set_wifi_profile_plugin.h" 20 #include "utils.h" 21 22 using namespace testing::ext; 23 using namespace testing; 24 25 namespace OHOS { 26 namespace EDM { 27 namespace TEST { 28 class SetWifiProfilePluginTest : public testing::Test { 29 protected: 30 static void SetUpTestSuite(void); 31 32 static void TearDownTestSuite(void); 33 }; 34 SetUpTestSuite(void)35void SetWifiProfilePluginTest::SetUpTestSuite(void) 36 { 37 Utils::SetEdmInitialEnv(); 38 } 39 TearDownTestSuite(void)40void SetWifiProfilePluginTest::TearDownTestSuite(void) 41 { 42 Utils::ResetTokenTypeAndUid(); 43 ASSERT_TRUE(Utils::IsOriginalUTEnv()); 44 std::cout << "now ut process is orignal ut env : " << Utils::IsOriginalUTEnv() << std::endl; 45 } 46 47 /** 48 * @tc.name: TestSetWifiProfile 49 * @tc.desc: Test SetWifiProfilePlugin::OnSetPolicy function when it is SYSTEM_ABNORMALLY. 50 * @tc.type: FUNC 51 */ 52 HWTEST_F(SetWifiProfilePluginTest, TestSetWifiProfile, TestSize.Level1) 53 { 54 Utils::ResetTokenTypeAndUid(); 55 SetWifiProfilePlugin plugin; 56 Wifi::WifiDeviceConfig config; 57 ErrCode ret = plugin.OnSetPolicy(config); 58 ASSERT_TRUE(ret == EdmReturnErrCode::SYSTEM_ABNORMALLY); 59 Utils::ResetTokenTypeAndUid(); 60 } 61 } // namespace TEST 62 } // namespace EDM 63 } // namespace OHOS