1 /*
2 * Copyright (c) 2021 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 <thread>
17 #include <unistd.h>
18 #include <vector>
19 #include <gtest/gtest.h>
20 #include "stream_pipeline_strategy.h"
21
22 using namespace testing::ext;
23 namespace OHOS::Camera {
24 class StrategyTest : public testing::Test {
25 public:
26 static void SetUpTestCase(void);
27 static void TearDownTestCase(void);
28
29 void SetUp(void);
30 void TearDown(void);
31 };
32
SetUpTestCase(void)33 void StrategyTest::SetUpTestCase(void)
34 {
35 std::cout << "Camera::StrategyTest SetUpTestCase" << std::endl;
36 }
37
TearDownTestCase(void)38 void StrategyTest::TearDownTestCase(void)
39 {
40 std::cout << "Camera::StrategyTest TearDownTestCase" << std::endl;
41 }
42
SetUp(void)43 void StrategyTest::SetUp(void)
44 {
45 std::cout << "Camera::StrategyTest SetUp" << std::endl;
46 }
47
TearDown(void)48 void StrategyTest::TearDown(void)
49 {
50 std::cout << "Camera::StrategyTest TearDown.." << std::endl;
51 }
52
53 HWTEST_F(StrategyTest, NormalPreviewTest, TestSize.Level0)
54 {
55 std::shared_ptr<HostStreamMgr> streamMgr = HostStreamMgr::Create();
56 streamMgr->CreateHostStream({
57 .type_ = PREVIEW
58 }, nullptr);
59 std::unique_ptr<StreamPipelineStrategy> s = StreamPipelineStrategy::Create(streamMgr);
60 EXPECT_TRUE(s != nullptr);
61 std::shared_ptr<PipelineSpec> spec = s->GeneratePipelineSpec(0);
62 EXPECT_TRUE(spec != nullptr);
63 }
64
65 HWTEST_F(StrategyTest, NormalSnapshotTest, TestSize.Level0)
66 {
67 std::shared_ptr<HostStreamMgr> streamMgr = HostStreamMgr::Create();
68 streamMgr->CreateHostStream({
69 .type_ = STILL_CAPTURE
70 }, nullptr);
71 std::unique_ptr<StreamPipelineStrategy> s = StreamPipelineStrategy::Create(streamMgr);
72 EXPECT_TRUE(s != nullptr);
73 std::shared_ptr<PipelineSpec> spec = s->GeneratePipelineSpec(0);
74 EXPECT_TRUE(spec != nullptr);
75 }
76
77 HWTEST_F(StrategyTest, NormalPreviewSnapshotTest, TestSize.Level0)
78 {
79 std::shared_ptr<HostStreamMgr> streamMgr = HostStreamMgr::Create();
80 streamMgr->CreateHostStream({
81 .type_ = PREVIEW
82 }, nullptr);
83 streamMgr->CreateHostStream({
84 .type_ = STILL_CAPTURE
85 }, nullptr);
86 std::unique_ptr<StreamPipelineStrategy> s = StreamPipelineStrategy::Create(streamMgr);
87 EXPECT_TRUE(s != nullptr);
88 std::shared_ptr<PipelineSpec> spec = s->GeneratePipelineSpec(0);
89 EXPECT_TRUE(spec != nullptr);
90 }
91
92 HWTEST_F(StrategyTest, AbNormalTest, TestSize.Level0)
93 {
94 std::shared_ptr<HostStreamMgr> streamMgr = HostStreamMgr::Create();
95 std::unique_ptr<StreamPipelineStrategy> s = StreamPipelineStrategy::Create(streamMgr);
96 std::shared_ptr<PipelineSpec> spec = s->GeneratePipelineSpec(1);
97 EXPECT_TRUE(spec == nullptr);
98 }
99 }
100