• 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 
16 #ifndef PREPARE_MOCK_SA_INTERCEPTOR_H
17 #define PREPARE_MOCK_SA_INTERCEPTOR_H
18 
19 #include "rule.h"
20 #include "sa_interceptor_stub.h"
21 
22 namespace OHOS {
23 namespace AbilityRuntime {
24 constexpr int32_t TYPE_NOT_ALLOW = 1;
25 constexpr int32_t TYPE_USER_SELECTION = 2;
26 
27 class MockSAInterceptorStub : public SAInterceptorStub {
28 public:
MockSAInterceptorStub(int type)29     MockSAInterceptorStub(int type) : type_(type) {}
~MockSAInterceptorStub()30     ~MockSAInterceptorStub() {}
OnCheckStarting(const std::string & params,Rule & rule)31     int32_t OnCheckStarting(const std::string &params, Rule &rule) override
32     {
33         switch (type_) {
34             case TYPE_NOT_ALLOW : {
35                 rule.type = RuleType::NOT_ALLOW;
36                 break;
37             }
38             case TYPE_USER_SELECTION : {
39                 rule.type = RuleType::USER_SELECTION;
40                 break;
41             }
42             default:
43                 break;
44         }
45         return 0;
46     }
47 private:
48     int type_;
49 };
50 } // namespace AbilityRuntime
51 } // namespace OHOS
52 #endif // PREPARE_MOCK_SA_INTERCEPTOR_H