0021_output_resolution: Use GetScreenSize to verify test result 05/314605/3
authorJunseok Kim <juns.kim@samsung.com>
Tue, 16 Jul 2024 05:45:59 +0000 (14:45 +0900)
committerJunseok Kim <juns.kim@samsung.com>
Tue, 16 Jul 2024 05:52:24 +0000 (14:52 +0900)
Change-Id: I911515b2a17b1e81026adc383bb6b48301d88faa

src/testcase/0021_output_resolution.cpp

index cc363f9db79e5293727ac86e33fc3221bc62021d..77def327b81f0302f4a4561d522cde3355f121a4 100644 (file)
@@ -37,19 +37,46 @@ etTestOutputResolution::initTC()
 
 TEST_F(etTestOutputResolution, basic)
 {
-   int res = 0;
+   Eina_Bool res = 0;
+   const int win_w = 100, win_h = 100;
+   int screen_w = 0, screen_h = 0;
+   double ratio_w = 1.0, ratio_h = 1.0;
+
+   etWin *tw = NULL;
+   Eina_List *list = NULL, *l = NULL;
 
    etTCResult initRes = initTC();
    ASSERT_TRUE(initRes.result()) << initRes.description();
 
    res = etRunner::get().setConfiguredOutputResolution(CONFIGURED_OUTPUT_RESOLUTION_W, CONFIGURED_OUTPUT_RESOLUTION_H);
-   ASSERT_EQ(res, 1);
+   ASSERT_EQ(res, EINA_TRUE);
 
-   tw_red = initNormalWin("TCWin_Red", 0, 0, 100, 100, E_TC_WIN_COLOR_RED);
+   tw_red = initNormalWin("TCWin_Red", 0, 0, win_w, win_h, E_TC_WIN_COLOR_RED);
    showTCWin(tw_red);
    ASSERT_FOCUS_IN(tw_red);
    ASSERT_TRUE(tw_red != NULL) << "failed to initiation window";
 
+   res = etRunner::get().getScreenSize(&screen_w, &screen_h);
+   ASSERT_EQ(res, EINA_TRUE) << "failed to get screen size";
+   ratio_w = (double) screen_w / CONFIGURED_OUTPUT_RESOLUTION_W;
+   ratio_h = (double) screen_h / CONFIGURED_OUTPUT_RESOLUTION_H;
+
+   // Expected window size res:
+   // tw_red.w = ratio_w * win_w (150 as FHD screen)
+   // tw_red.h = ratio_h * win_h (150 as FHD screen)
+   list = etRunner::get().getWinInfoList();
+   ASSERT_TRUE(list != NULL);
+
+   EINA_LIST_CAST_FOREACH(list, l, tw, etWin*)
+     {
+        if (tw->native_win == tw_red->native_win)
+          {
+             ASSERT_EQ(tw->w, ratio_w * win_w);
+             ASSERT_EQ(tw->h, ratio_h * win_h);
+          }
+     }
+   etRunner::get().freeWinInfoList(list);
+
    res = etRunner::get().unsetConfiguredOutputResolution();
    ASSERT_EQ(res, 0);
 
@@ -58,21 +85,48 @@ TEST_F(etTestOutputResolution, basic)
 
 TEST_F(etTestOutputResolution, base_output_resolution_basic)
 {
-   int res = 0;
+   Eina_Bool res = 0;
+   const int win_w = 100, win_h = 100;
+   int screen_w = 0, screen_h = 0;
+   double ratio_w = 1.0, ratio_h = 1.0;
+
+   etWin *tw = NULL;
+   Eina_List *list = NULL, *l = NULL;
 
    etTCResult initRes = initTC();
    ASSERT_TRUE(initRes.result()) << initRes.description();
 
    res = etRunner::get().setConfiguredOutputResolution(CONFIGURED_OUTPUT_RESOLUTION_W, CONFIGURED_OUTPUT_RESOLUTION_H);
-   ASSERT_EQ(res, 1);
+   ASSERT_EQ(res, EINA_TRUE);
    res = etRunner::get().setBaseOutputResolution(getpid(), BASE_OUTPUT_RESOLUTION_W, BASE_OUTPUT_RESOLUTION_H);
-   ASSERT_EQ(res, 1);
+   ASSERT_EQ(res, EINA_TRUE);
 
-   tw_red = initNormalWin("TCWin_Red", 0, 0, 100, 100, E_TC_WIN_COLOR_RED);
+   tw_red = initNormalWin("TCWin_Red", 0, 0, win_w, win_h, E_TC_WIN_COLOR_RED);
    showTCWin(tw_red);
    ASSERT_FOCUS_IN(tw_red);
    ASSERT_TRUE(tw_red != NULL) << "failed to initiation window";
 
+   res = etRunner::get().getScreenSize(&screen_w, &screen_h);
+   ASSERT_EQ(res, EINA_TRUE) << "failed to get screen size";
+   ratio_w = (double) screen_w / BASE_OUTPUT_RESOLUTION_W;
+   ratio_h = (double) screen_h / BASE_OUTPUT_RESOLUTION_H;
+
+   // Expected window size res:
+   // tw_red.w = ratio_w * win_w (300 as FHD screen)
+   // tw_red.h = ratio_h * win_h (200 as FHD screen)
+   list = etRunner::get().getWinInfoList();
+   ASSERT_TRUE(list != NULL);
+
+   EINA_LIST_CAST_FOREACH(list, l, tw, etWin*)
+     {
+        if (tw->native_win == tw_red->native_win)
+          {
+             ASSERT_EQ(tw->w, ratio_w * win_w);
+             ASSERT_EQ(tw->h, ratio_h * win_h);
+          }
+     }
+   etRunner::get().freeWinInfoList(list);
+
    res = etRunner::get().unsetBaseOutputResolution(getpid());
    ASSERT_EQ(res, 0);