diff options
Diffstat (limited to 'test/utils-fake.h')
-rw-r--r-- | test/utils-fake.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/test/utils-fake.h b/test/utils-fake.h index a3cd3d7..dd93542 100644 --- a/test/utils-fake.h +++ b/test/utils-fake.h | |||
@@ -78,6 +78,35 @@ class MockPartitionMounter : public PartitionMounter { | |||
78 | bool vendorMounted_; | 78 | bool vendorMounted_; |
79 | }; | 79 | }; |
80 | 80 | ||
81 | class MockRuntimeInfo : public RuntimeInfo { | ||
82 | public: | ||
83 | MockRuntimeInfo() { | ||
84 | ON_CALL(*this, fetchAllInformation(_)) | ||
85 | .WillByDefault(Invoke(this, &MockRuntimeInfo::doFetch)); | ||
86 | } | ||
87 | MOCK_METHOD1(fetchAllInformation, status_t(RuntimeInfo::FetchFlags)); | ||
88 | status_t doFetch(RuntimeInfo::FetchFlags flags) { | ||
89 | if (failNextFetch_) { | ||
90 | failNextFetch_ = false; | ||
91 | return android::UNKNOWN_ERROR; | ||
92 | } | ||
93 | return RuntimeInfo::fetchAllInformation(flags); | ||
94 | } | ||
95 | void failNextFetch() { failNextFetch_ = true; } | ||
96 | |||
97 | private: | ||
98 | bool failNextFetch_ = false; | ||
99 | }; | ||
100 | class MockRuntimeInfoFactory : public ObjectFactory<RuntimeInfo> { | ||
101 | public: | ||
102 | MockRuntimeInfoFactory(const std::shared_ptr<MockRuntimeInfo>& info) { object_ = info; } | ||
103 | std::shared_ptr<RuntimeInfo> make_shared() const override { return object_; } | ||
104 | std::shared_ptr<MockRuntimeInfo> getInfo() const { return object_; } | ||
105 | |||
106 | private: | ||
107 | std::shared_ptr<MockRuntimeInfo> object_; | ||
108 | }; | ||
109 | |||
81 | } // namespace details | 110 | } // namespace details |
82 | } // namespace vintf | 111 | } // namespace vintf |
83 | } // namespace android | 112 | } // namespace android |