diff --git a/fs_mgr/liblp/builder_test.cpp b/fs_mgr/liblp/builder_test.cpp index ecad7d49e..dde6d07c9 100644 --- a/fs_mgr/liblp/builder_test.cpp +++ b/fs_mgr/liblp/builder_test.cpp @@ -19,29 +19,20 @@ #include #include "liblp_test.h" -#include "mock_property_fetcher.h" #include "utility.h" using namespace std; using namespace android::fs_mgr; -using ::android::fs_mgr::MockPropertyFetcher; +using namespace android::fs_mgr::testing; using ::testing::_; using ::testing::AnyNumber; using ::testing::ElementsAre; using ::testing::NiceMock; using ::testing::Return; -void ResetPropertyFetcher() { - IPropertyFetcher::OverrideForTesting(std::make_unique>()); -} - -MockPropertyFetcher* GetMockedPropertyFetcher() { - return static_cast(IPropertyFetcher::GetInstance()); -} - class Environment : public ::testing::Environment { public: - void SetUp() override { ResetPropertyFetcher(); } + void SetUp() override { ResetMockPropertyFetcher(); } }; int main(int argc, char** argv) { diff --git a/fs_mgr/liblp/device_test.cpp b/fs_mgr/liblp/device_test.cpp index b759fd11f..382d53d52 100644 --- a/fs_mgr/liblp/device_test.cpp +++ b/fs_mgr/liblp/device_test.cpp @@ -24,9 +24,9 @@ #include #include "liblp_test.h" -#include "mock_property_fetcher.h" using namespace android::fs_mgr; +using namespace android::fs_mgr::testing; using ::testing::Return; // Compliance test on the actual device with dynamic partitions. diff --git a/fs_mgr/liblp/mock_property_fetcher.h b/fs_mgr/liblp/include/liblp/mock_property_fetcher.h similarity index 79% rename from fs_mgr/liblp/mock_property_fetcher.h rename to fs_mgr/liblp/include/liblp/mock_property_fetcher.h index 4612c5290..f15611b48 100644 --- a/fs_mgr/liblp/mock_property_fetcher.h +++ b/fs_mgr/liblp/include/liblp/mock_property_fetcher.h @@ -22,6 +22,7 @@ namespace android { namespace fs_mgr { +namespace testing { class MockPropertyFetcher : public IPropertyFetcher { public: @@ -41,8 +42,15 @@ class MockPropertyFetcher : public IPropertyFetcher { } }; +static inline void ResetMockPropertyFetcher() { + IPropertyFetcher::OverrideForTesting( + std::make_unique<::testing::NiceMock>()); +} + +static inline MockPropertyFetcher* GetMockedPropertyFetcher() { + return static_cast(IPropertyFetcher::GetInstance()); +} + +} // namespace testing } // namespace fs_mgr } // namespace android - -android::fs_mgr::MockPropertyFetcher* GetMockedPropertyFetcher(); -void ResetPropertyFetcher(); diff --git a/fs_mgr/liblp/io_test.cpp b/fs_mgr/liblp/io_test.cpp index 4d0094486..df89e9c90 100644 --- a/fs_mgr/liblp/io_test.cpp +++ b/fs_mgr/liblp/io_test.cpp @@ -27,7 +27,6 @@ #include "images.h" #include "liblp_test.h" -#include "mock_property_fetcher.h" #include "reader.h" #include "test_partition_opener.h" #include "utility.h" @@ -35,6 +34,7 @@ using namespace std; using namespace android::fs_mgr; +using namespace android::fs_mgr::testing; using ::testing::_; using ::testing::Return; using unique_fd = android::base::unique_fd; diff --git a/fs_mgr/liblp/liblp_test.h b/fs_mgr/liblp/liblp_test.h index 892f43d12..c61aaa545 100644 --- a/fs_mgr/liblp/liblp_test.h +++ b/fs_mgr/liblp/liblp_test.h @@ -18,10 +18,18 @@ #include -#include "mock_property_fetcher.h" +#include + +namespace android { +namespace fs_mgr { +namespace testing { class LiblpTest : public ::testing::Test { public: - void SetUp() override { ResetPropertyFetcher(); } - void TearDown() override { ResetPropertyFetcher(); } + void SetUp() override { ResetMockPropertyFetcher(); } + void TearDown() override { ResetMockPropertyFetcher(); } }; + +} // namespace testing +} // namespace fs_mgr +} // namespace android