• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2020, The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef CPP_WATCHDOG_SERVER_TESTS_MOCKCARWATCHDOGSERVICEFORSYSTEM_H_
18 #define CPP_WATCHDOG_SERVER_TESTS_MOCKCARWATCHDOGSERVICEFORSYSTEM_H_
19 
20 #include "MockBinder.h"
21 
22 #include <android/automotive/watchdog/internal/ICarWatchdogServiceForSystem.h>
23 #include <android/automotive/watchdog/internal/TimeoutLength.h>
24 #include <binder/Status.h>
25 #include <gmock/gmock.h>
26 #include <utils/RefBase.h>
27 #include <utils/StrongPointer.h>
28 
29 namespace android {
30 namespace automotive {
31 namespace watchdog {
32 
33 class MockCarWatchdogServiceForSystem :
34       public android::automotive::watchdog::internal::ICarWatchdogServiceForSystemDefault {
35 public:
MockCarWatchdogServiceForSystem()36     MockCarWatchdogServiceForSystem() : mBinder(new MockBinder()) {
37         ON_CALL(*this, onAsBinder()).WillByDefault(::testing::Return(mBinder.get()));
38     }
39 
getBinder()40     android::sp<MockBinder> getBinder() const { return mBinder; }
41 
42     MOCK_METHOD(android::IBinder*, onAsBinder, (), (override));
43     MOCK_METHOD(android::binder::Status, checkIfAlive,
44                 (int32_t, android::automotive::watchdog::internal::TimeoutLength), (override));
45     MOCK_METHOD(android::binder::Status, prepareProcessTermination, (), (override));
46     MOCK_METHOD(android::binder::Status, getPackageInfosForUids,
47                 (const std::vector<int32_t>&, const std::vector<std::string>&,
48                  std::vector<android::automotive::watchdog::internal::PackageInfo>*),
49                 (override));
50     MOCK_METHOD(
51             android::binder::Status, latestIoOveruseStats,
52             (const std::vector<android::automotive::watchdog::internal::PackageIoOveruseStats>&),
53             (override));
54     MOCK_METHOD(android::binder::Status, resetResourceOveruseStats,
55                 (const std::vector<std::string>&), (override));
56 
57 private:
58     android::sp<MockBinder> mBinder;
59 };
60 
61 }  // namespace watchdog
62 }  // namespace automotive
63 }  // namespace android
64 
65 #endif  //  CPP_WATCHDOG_SERVER_TESTS_MOCKCARWATCHDOGSERVICEFORSYSTEM_H_
66