1 /*
2 * Copyright (C) 2024 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 "simcard_setting_asset_test.h"
17 #include "ringtone_type.h"
18 #include "ringtone_db_const.h"
19 #include "simcard_setting_asset.h"
20 #include "ringtone_errno.h"
21
22 using namespace std;
23 using namespace OHOS;
24 using namespace testing::ext;
25
26 namespace OHOS {
27 namespace Media {
28 shared_ptr<SimcardSettingAsset> g_simcardSettingAsset;
29
SetUpTestCase()30 void SimcardSettingAssetTest::SetUpTestCase()
31 {
32 g_simcardSettingAsset = std::make_shared<SimcardSettingAsset>();
33 EXPECT_NE(g_simcardSettingAsset, nullptr);
34 }
35
TearDownTestCase()36 void SimcardSettingAssetTest::TearDownTestCase() {}
37
38 // SetUp:Execute before each test case
SetUp()39 void SimcardSettingAssetTest::SetUp() {}
40
TearDown(void)41 void SimcardSettingAssetTest::TearDown(void) {}
42
43 HWTEST_F(SimcardSettingAssetTest, simcardSettingAsset_GetMode_test_001, TestSize.Level0)
44 {
45 auto mode = g_simcardSettingAsset->GetMode();
46 EXPECT_EQ(mode, RING_TONE_TYPE_NOT);
47 }
48
49 HWTEST_F(SimcardSettingAssetTest, simcardSettingAsset_SetMode_test_001, TestSize.Level0)
50 {
51 auto mode = g_simcardSettingAsset->GetMode();
52 EXPECT_EQ(mode, RING_TONE_TYPE_NOT);
53 const int32_t newMode = RING_TONE_TYPE_SIM_CARD_2;
54 g_simcardSettingAsset->SetMode(newMode);
55 mode = g_simcardSettingAsset->GetMode();
56 EXPECT_EQ(mode, newMode);
57 }
58
59 HWTEST_F(SimcardSettingAssetTest, simcardSettingAsset_SetToneFile_test_001, TestSize.Level0)
60 {
61 auto toneFile = g_simcardSettingAsset->GetToneFile();
62 EXPECT_EQ(toneFile, RINGTONE_DEFAULT_STR);
63 const std::string newToneFile = ROOT_TONE_PRELOAD_PATH_NOAH_PATH;
64 g_simcardSettingAsset->SetToneFile(newToneFile);
65 toneFile = g_simcardSettingAsset->GetToneFile();
66 EXPECT_EQ(toneFile, newToneFile);
67 }
68
69 HWTEST_F(SimcardSettingAssetTest, simcardSettingAsset_SetVibrateFile_test_001, TestSize.Level0)
70 {
71 auto vibrateFile = g_simcardSettingAsset->GetVibrateFile();
72 EXPECT_EQ(vibrateFile, RINGTONE_DEFAULT_STR);
73 const std::string newVibrateFile = ROOT_TONE_PRELOAD_PATH_NOAH_PATH;
74 g_simcardSettingAsset->SetVibrateFile(newVibrateFile);
75 vibrateFile = g_simcardSettingAsset->GetVibrateFile();
76 EXPECT_EQ(vibrateFile, newVibrateFile);
77 }
78 } // namespace Media
79 } // namespace OHOS
80