• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "update_engine_test.h"
16 
17 #include <fstream>
18 #include <iostream>
19 
20 #include "json/json.h"
21 #include "update_engine.h"
22 #include "intell_voice_manager.h"
23 #include "engine_host_manager.h"
24 #include "intell_voice_log.h"
25 #include "intell_voice_service_manager.h"
26 #include "silence_update_strategy.h"
27 #include "i_intell_voice_engine.h"
28 #include "history_info_mgr.h"
29 
30 #define LOG_TAG "UpdateEngineTest"
31 
32 #define INTELL_VOICE_BUILD_VARIANT_ROOT
33 
34 using namespace testing;
35 using namespace testing::ext;
36 using namespace OHOS;
37 using namespace std;
38 using namespace OHOS::IntellVoiceTests;
39 using namespace OHOS::IntellVoice;
40 using namespace OHOS::IntellVoiceEngine;
41 using namespace OHOS::IntellVoiceUtils;
42 using namespace OHOS::HDI::IntelligentVoice::Engine::V1_0;
43 
44 #define private public
45 
46 namespace OHOS {
47 namespace IntellVoiceTests {
48 class TestWptr : public RefBase {
49 public:
Func()50     void Func()
51     {
52         wptr<TestWptr> thisWptr(this);
53         std::thread([thisWptr]() {
54             INTELL_VOICE_LOG_INFO("start");
55             sleep(1);
56             sptr<TestWptr> thisSptr = thisWptr.promote();
57             if (thisSptr != nullptr) {
58                 INTELL_VOICE_LOG_WARN("TestWptr not null");
59             } else {
60                 INTELL_VOICE_LOG_WARN("TestWptr is null");
61             }
62             INTELL_VOICE_LOG_INFO("end");
63         }).detach();
64     }
65 };
66 
SetUpTestCase(void)67 void UpdateEngineTest::SetUpTestCase(void)
68 {}
69 
TearDownTestCase(void)70 void UpdateEngineTest::TearDownTestCase(void)
71 {}
72 
SetUp(void)73 void UpdateEngineTest::SetUp(void)
74 {}
75 
TearDown(void)76 void UpdateEngineTest::TearDown(void)
77 {}
78 
79 /**
80  * @tc.name  : Test Template UpdateEngineTest
81  * @tc.number: UpdateEngineTest_001
82  * @tc.desc  : Test For Wptr
83  */
84 HWTEST_F(UpdateEngineTest, UpdateEngineTest_001, TestSize.Level1)
85 {
86     sptr<TestWptr> t = sptr<TestWptr>(new TestWptr());
87     t->Func();
88     t = nullptr;
89     ASSERT_EQ(nullptr, t);
90 }
91 }  // namespace IntellVoiceTests
92 }  // namespace OHOS