• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2025 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 #define MLOG_TAG "FileExtUnitTest"
16 
17 #include "ringtone_scan_executor_test.h"
18 
19 #include "ringtone_db_const.h"
20 #include "ringtone_errno.h"
21 #include "ringtone_log.h"
22 #include "ringtone_mimetype_utils.h"
23 #include "ringtone_scan_executor.h"
24 #include "ringtone_unittest_utils.h"
25 #include "ringtone_type.h"
26 #include <thread>
27 
28 using namespace std;
29 using namespace OHOS;
30 using namespace testing::ext;
31 
32 namespace OHOS {
33 namespace Media {
SetUpTestCase()34 void RingtoneScanExecutorTest::SetUpTestCase() {}
35 
TearDownTestCase()36 void RingtoneScanExecutorTest::TearDownTestCase() {}
37 
SetUp()38 void RingtoneScanExecutorTest::SetUp() {}
39 
TearDown(void)40 void RingtoneScanExecutorTest::TearDown(void) {}
41 
42 
43 HWTEST_F(RingtoneScanExecutorTest, ringtonelib_Commit_test_001, TestSize.Level0)
44 {
45     shared_ptr<RingtoneScanExecutor> ringtonescanexecutor = make_shared<RingtoneScanExecutor>();
46     EXPECT_NE(ringtonescanexecutor, nullptr);
47     ringtonescanexecutor->activeThread_ = 10;
48     std::shared_ptr<RingtoneScannerObj> scanner;
49     ringtonescanexecutor->Start();
50     int32_t ret = ringtonescanexecutor->Commit(scanner);
51     ringtonescanexecutor->isScanFinished = false;
__anonbcc72b0e0102() 52     std::thread stopThread([ringtonescanexecutor]() {
53         ringtonescanexecutor->Stop();
54     });
55     std::this_thread::sleep_for(std::chrono::milliseconds(100));
56     ringtonescanexecutor->stopCond.notify_one();
57     stopThread.join();
58     EXPECT_EQ(ret, 0);
59 }
60 } // namespace Media
61 } // namespace OHOS
62