From: Hwankyu Jhun Date: Fri, 8 Sep 2023 00:58:46 +0000 (+0900) Subject: Exclude code lines for code coverage X-Git-Tag: accepted/tizen/unified/20230911.091128~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=caa3e1561451a469a4930f79651c6a9d3af4e453;p=platform%2Fcore%2Fapi%2Fapplication.git Exclude code lines for code coverage Some code lines of unittests are excluded. Change-Id: Ida5868b136499ec45bc3069f22102acb19d565bd Signed-off-by: Hwankyu Jhun --- diff --git a/tests/application_unittests/app_main_legacy_test.cc b/tests/application_unittests/app_main_legacy_test.cc index ea22480..2473096 100644 --- a/tests/application_unittests/app_main_legacy_test.cc +++ b/tests/application_unittests/app_main_legacy_test.cc @@ -38,7 +38,9 @@ GMainLoop* loop_; void FakeRun(int argc, char** argv) {} +// LCOV_EXCL_START void FakeAddEvent(std::shared_ptr event) {} +// LCOV_EXCL_STOP bool FakeRemoveEvent(std::shared_ptr event) { return true; @@ -46,14 +48,6 @@ bool FakeRemoveEvent(std::shared_ptr event) { void FakeExit() {} -int FakeGetWindowPosition(int* x, int* y, int* w, int* h) { - *x = 1920; - *y = 1024; - *w = 1920; - *h = 1024; - return 0; -} - void FakeOnLoopInit(int argc, char** argv) { loop_ = g_main_loop_new(nullptr, FALSE); } @@ -83,6 +77,7 @@ void AppTerminateCb(void* user_data) {} void AppControlCb(app_control_h app_control, void* user_data) {} +// LCOV_EXCL_START void AppLowMemoryCb(void* user_data) {} void AppLowBatteryCb(void* user_data) {} @@ -93,6 +88,7 @@ void AppDeviceOrientationCb(app_device_orientation_e orientation, void AppLanguageChangedCb(void* user_data) {} void AppRegionFormatChangedCb(void* user_data) {} +// LCOV_EXCL_STOP } // namespace @@ -110,8 +106,6 @@ class AppMainLegacyTest : public TestFixture { .WillRepeatedly(Invoke(FakeAddEvent)); EXPECT_CALL(GetMock(), RemoveEvent(_)) .WillRepeatedly(Invoke(FakeRemoveEvent)); - EXPECT_CALL(GetMock(), GetWindowPosition(_, _, _, _)) - .WillRepeatedly(Invoke(FakeGetWindowPosition)); EXPECT_CALL(GetMock(), OnLoopInit(_, _)) .WillRepeatedly(Invoke(FakeOnLoopInit)); EXPECT_CALL(GetMock(), OnLoopFinish()) diff --git a/tests/application_unittests/app_main_test.cc b/tests/application_unittests/app_main_test.cc index f4efc8e..1581d22 100644 --- a/tests/application_unittests/app_main_test.cc +++ b/tests/application_unittests/app_main_test.cc @@ -38,11 +38,13 @@ GMainLoop* loop_; void FakeRun(int argc, char** argv) {} +// LCOV_EXCL_START void FakeAddEvent(std::shared_ptr event) {} bool FakeRemoveEvent(std::shared_ptr event) { return true; } +// LCOV_EXCL_STOP void FakeExit() {} @@ -83,7 +85,7 @@ void AppTerminateCb(void* user_data) {} void AppControlCb(app_control_h app_control, void* user_data) {} -void AppEventCb(app_event_info_h event_info, void* user_data) {} +void AppEventCb(app_event_info_h event_info, void* user_data) {} // LCOV_EXCL_LINE } // namespace diff --git a/tests/application_unittests/main.cc b/tests/application_unittests/main.cc index f1c49aa..3d9fd45 100644 --- a/tests/application_unittests/main.cc +++ b/tests/application_unittests/main.cc @@ -22,7 +22,9 @@ int main(int argc, char** argv) { testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } catch (std::exception const &e) { + // LCOV_EXCL_START std::cout << "test_main caught exception: " << e.what() << std::endl; return -1; + // LCOV_EXCL_STOP } } diff --git a/tests/application_unittests/mock/test_fixture.hh b/tests/application_unittests/mock/test_fixture.hh index 0b1a1bc..49c5873 100644 --- a/tests/application_unittests/mock/test_fixture.hh +++ b/tests/application_unittests/mock/test_fixture.hh @@ -35,15 +35,19 @@ class TestFixture : public ::testing::Test { mock_.reset(); } - virtual void SetUp() {} - virtual void TearDown() {} + virtual void SetUp() {} // LCOV_EXCL_LINE + virtual void TearDown() {} // LCOV_EXCL_LINE template static T& GetMock() { auto ptr = dynamic_cast(mock_.get()); - if (!ptr) + if (!ptr) { + // LCOV_EXCL_START throw std::invalid_argument("The test does not provide mock of \"" + std::string(typeid(T).name()) + "\""); + // LCOV_EXCL_STOP + } + return *ptr; }