Loading fs_mgr/liblp/builder_test.cpp +2 −11 Original line number Original line Diff line number Diff line Loading @@ -19,29 +19,20 @@ #include <liblp/builder.h> #include <liblp/builder.h> #include "liblp_test.h" #include "liblp_test.h" #include "mock_property_fetcher.h" #include "utility.h" #include "utility.h" using namespace std; using namespace std; using namespace android::fs_mgr; using namespace android::fs_mgr; using ::android::fs_mgr::MockPropertyFetcher; using namespace android::fs_mgr::testing; using ::testing::_; using ::testing::_; using ::testing::AnyNumber; using ::testing::AnyNumber; using ::testing::ElementsAre; using ::testing::ElementsAre; using ::testing::NiceMock; using ::testing::NiceMock; using ::testing::Return; using ::testing::Return; void ResetPropertyFetcher() { IPropertyFetcher::OverrideForTesting(std::make_unique<NiceMock<MockPropertyFetcher>>()); } MockPropertyFetcher* GetMockedPropertyFetcher() { return static_cast<MockPropertyFetcher*>(IPropertyFetcher::GetInstance()); } class Environment : public ::testing::Environment { class Environment : public ::testing::Environment { public: public: void SetUp() override { ResetPropertyFetcher(); } void SetUp() override { ResetMockPropertyFetcher(); } }; }; int main(int argc, char** argv) { int main(int argc, char** argv) { Loading fs_mgr/liblp/device_test.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -24,9 +24,9 @@ #include <liblp/property_fetcher.h> #include <liblp/property_fetcher.h> #include "liblp_test.h" #include "liblp_test.h" #include "mock_property_fetcher.h" using namespace android::fs_mgr; using namespace android::fs_mgr; using namespace android::fs_mgr::testing; using ::testing::Return; using ::testing::Return; // Compliance test on the actual device with dynamic partitions. // Compliance test on the actual device with dynamic partitions. Loading fs_mgr/liblp/mock_property_fetcher.h→fs_mgr/liblp/include/liblp/mock_property_fetcher.h +11 −3 Original line number Original line Diff line number Diff line Loading @@ -22,6 +22,7 @@ namespace android { namespace android { namespace fs_mgr { namespace fs_mgr { namespace testing { class MockPropertyFetcher : public IPropertyFetcher { class MockPropertyFetcher : public IPropertyFetcher { public: public: Loading @@ -41,8 +42,15 @@ class MockPropertyFetcher : public IPropertyFetcher { } } }; }; static inline void ResetMockPropertyFetcher() { IPropertyFetcher::OverrideForTesting( std::make_unique<::testing::NiceMock<MockPropertyFetcher>>()); } static inline MockPropertyFetcher* GetMockedPropertyFetcher() { return static_cast<MockPropertyFetcher*>(IPropertyFetcher::GetInstance()); } } // namespace testing } // namespace fs_mgr } // namespace fs_mgr } // namespace android } // namespace android android::fs_mgr::MockPropertyFetcher* GetMockedPropertyFetcher(); void ResetPropertyFetcher(); fs_mgr/liblp/io_test.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -27,7 +27,6 @@ #include "images.h" #include "images.h" #include "liblp_test.h" #include "liblp_test.h" #include "mock_property_fetcher.h" #include "reader.h" #include "reader.h" #include "test_partition_opener.h" #include "test_partition_opener.h" #include "utility.h" #include "utility.h" Loading @@ -35,6 +34,7 @@ using namespace std; using namespace std; using namespace android::fs_mgr; using namespace android::fs_mgr; using namespace android::fs_mgr::testing; using ::testing::_; using ::testing::_; using ::testing::Return; using ::testing::Return; using unique_fd = android::base::unique_fd; using unique_fd = android::base::unique_fd; Loading fs_mgr/liblp/liblp_test.h +11 −3 Original line number Original line Diff line number Diff line Loading @@ -18,10 +18,18 @@ #include <gtest/gtest.h> #include <gtest/gtest.h> #include "mock_property_fetcher.h" #include <liblp/mock_property_fetcher.h> namespace android { namespace fs_mgr { namespace testing { class LiblpTest : public ::testing::Test { class LiblpTest : public ::testing::Test { public: public: void SetUp() override { ResetPropertyFetcher(); } void SetUp() override { ResetMockPropertyFetcher(); } void TearDown() override { ResetPropertyFetcher(); } void TearDown() override { ResetMockPropertyFetcher(); } }; }; } // namespace testing } // namespace fs_mgr } // namespace android Loading
fs_mgr/liblp/builder_test.cpp +2 −11 Original line number Original line Diff line number Diff line Loading @@ -19,29 +19,20 @@ #include <liblp/builder.h> #include <liblp/builder.h> #include "liblp_test.h" #include "liblp_test.h" #include "mock_property_fetcher.h" #include "utility.h" #include "utility.h" using namespace std; using namespace std; using namespace android::fs_mgr; using namespace android::fs_mgr; using ::android::fs_mgr::MockPropertyFetcher; using namespace android::fs_mgr::testing; using ::testing::_; using ::testing::_; using ::testing::AnyNumber; using ::testing::AnyNumber; using ::testing::ElementsAre; using ::testing::ElementsAre; using ::testing::NiceMock; using ::testing::NiceMock; using ::testing::Return; using ::testing::Return; void ResetPropertyFetcher() { IPropertyFetcher::OverrideForTesting(std::make_unique<NiceMock<MockPropertyFetcher>>()); } MockPropertyFetcher* GetMockedPropertyFetcher() { return static_cast<MockPropertyFetcher*>(IPropertyFetcher::GetInstance()); } class Environment : public ::testing::Environment { class Environment : public ::testing::Environment { public: public: void SetUp() override { ResetPropertyFetcher(); } void SetUp() override { ResetMockPropertyFetcher(); } }; }; int main(int argc, char** argv) { int main(int argc, char** argv) { Loading
fs_mgr/liblp/device_test.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -24,9 +24,9 @@ #include <liblp/property_fetcher.h> #include <liblp/property_fetcher.h> #include "liblp_test.h" #include "liblp_test.h" #include "mock_property_fetcher.h" using namespace android::fs_mgr; using namespace android::fs_mgr; using namespace android::fs_mgr::testing; using ::testing::Return; using ::testing::Return; // Compliance test on the actual device with dynamic partitions. // Compliance test on the actual device with dynamic partitions. Loading
fs_mgr/liblp/mock_property_fetcher.h→fs_mgr/liblp/include/liblp/mock_property_fetcher.h +11 −3 Original line number Original line Diff line number Diff line Loading @@ -22,6 +22,7 @@ namespace android { namespace android { namespace fs_mgr { namespace fs_mgr { namespace testing { class MockPropertyFetcher : public IPropertyFetcher { class MockPropertyFetcher : public IPropertyFetcher { public: public: Loading @@ -41,8 +42,15 @@ class MockPropertyFetcher : public IPropertyFetcher { } } }; }; static inline void ResetMockPropertyFetcher() { IPropertyFetcher::OverrideForTesting( std::make_unique<::testing::NiceMock<MockPropertyFetcher>>()); } static inline MockPropertyFetcher* GetMockedPropertyFetcher() { return static_cast<MockPropertyFetcher*>(IPropertyFetcher::GetInstance()); } } // namespace testing } // namespace fs_mgr } // namespace fs_mgr } // namespace android } // namespace android android::fs_mgr::MockPropertyFetcher* GetMockedPropertyFetcher(); void ResetPropertyFetcher();
fs_mgr/liblp/io_test.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -27,7 +27,6 @@ #include "images.h" #include "images.h" #include "liblp_test.h" #include "liblp_test.h" #include "mock_property_fetcher.h" #include "reader.h" #include "reader.h" #include "test_partition_opener.h" #include "test_partition_opener.h" #include "utility.h" #include "utility.h" Loading @@ -35,6 +34,7 @@ using namespace std; using namespace std; using namespace android::fs_mgr; using namespace android::fs_mgr; using namespace android::fs_mgr::testing; using ::testing::_; using ::testing::_; using ::testing::Return; using ::testing::Return; using unique_fd = android::base::unique_fd; using unique_fd = android::base::unique_fd; Loading
fs_mgr/liblp/liblp_test.h +11 −3 Original line number Original line Diff line number Diff line Loading @@ -18,10 +18,18 @@ #include <gtest/gtest.h> #include <gtest/gtest.h> #include "mock_property_fetcher.h" #include <liblp/mock_property_fetcher.h> namespace android { namespace fs_mgr { namespace testing { class LiblpTest : public ::testing::Test { class LiblpTest : public ::testing::Test { public: public: void SetUp() override { ResetPropertyFetcher(); } void SetUp() override { ResetMockPropertyFetcher(); } void TearDown() override { ResetPropertyFetcher(); } void TearDown() override { ResetMockPropertyFetcher(); } }; }; } // namespace testing } // namespace fs_mgr } // namespace android