• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef FOUNDATION_ACE_FRAMEWORKS_BRIDGE_TEST_UNITTEST_CARDFRONTEND_CARD_TEST_FACTORY_H
17 #define FOUNDATION_ACE_FRAMEWORKS_BRIDGE_TEST_UNITTEST_CARDFRONTEND_CARD_TEST_FACTORY_H
18 
19 #include <cstdint>
20 
21 #include "base/memory/referenced.h"
22 #include "base/utils/noncopyable.h"
23 #include "base/utils/singleton.h"
24 #include "frameworks/bridge/card_frontend/js_card_parser.h"
25 
26 namespace OHOS::Ace::Framework {
27 
28 class CardTestFactory : public Singleton<CardTestFactory> {
29     DECLARE_SINGLETON(CardTestFactory);
30     ACE_DISALLOW_MOVE(CardTestFactory);
31 
32 public:
33     void ParseCardDsl(const RefPtr<JsAcePage>& page, const std::string& content);
34     void ParseCardDslWithParams(const RefPtr<JsAcePage>& page, const std::string& content, const std::string& params);
35 
GetNodeNumber()36     int32_t GetNodeNumber()
37     {
38         int32_t cnt = nodeCnt_;
39         nodeCnt_ = 0;
40         return cnt;
41     }
42 
43 private:
44     void FlushCommands(const RefPtr<Framework::JsAcePage>& page);
45     int32_t nodeCnt_ = 0;
46     RefPtr<PipelineContext> context_;
47 };
48 
49 } // namespace OHOS::Ace::Framework
50 
51 #endif // FOUNDATION_ACE_FRAMEWORKS_BRIDGE_TEST_UNITTEST_CARDFRONTEND_CARD_TEST_FACTORY_H
52