1 /*
2  * Copyright (c) 2022 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 OHOS_ABILITY_RUNTIME_ABILITY_DELEGATOR_REGISTRY_H
17 #define OHOS_ABILITY_RUNTIME_ABILITY_DELEGATOR_REGISTRY_H
18 
19 #include <memory>
20 #include "ability_delegator.h"
21 #include "ability_delegator_args.h"
22 
23 namespace OHOS {
24 namespace AppExecFwk {
25 class AbilityDelegatorRegistry {
26 public:
27     /**
28      * Obtains the AbilityDelegator object of the application.
29      *
30      * @return the AbilityDelegator object initialized when the application is started.
31      */
32     static std::shared_ptr<AbilityDelegator> GetAbilityDelegator();
33 
34     /**
35      * Obtains test parameters stored in the AbilityDelegatorArgs object.
36      *
37      * @return the previously registered AbilityDelegatorArgs object.
38      */
39     static std::shared_ptr<AbilityDelegatorArgs> GetArguments();
40 
41     /**
42      * Registers the instances of AbilityDelegator and AbilityDelegatorArgs as globally unique instances.
43      * This method is called during application startup to initialize the test environment.
44      *
45      * @param delegator, Indicates the AbilityDelegator object.
46      * @param args, Indicates the AbilityDelegatorArgs object.
47      */
48     static void RegisterInstance(
49         const std::shared_ptr<AbilityDelegator> &delegator, const std::shared_ptr<AbilityDelegatorArgs> &args);
50 
51 private:
52     static std::shared_ptr<AbilityDelegator> abilityDelegator_;
53     static std::shared_ptr<AbilityDelegatorArgs> abilityDelegatorArgs_;
54 };
55 }  // namespace AppExecFwk
56 }  // namespace OHOS
57 
58 #endif  // OHOS_ABILITY_RUNTIME_ABILITY_DELEGATOR_REGISTRY_H
59