desk_test_util.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. // Copyright 2022 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef COMPONENTS_DESKS_STORAGE_CORE_DESK_TEST_UTIL_H_
  5. #define COMPONENTS_DESKS_STORAGE_CORE_DESK_TEST_UTIL_H_
  6. #include "components/account_id/account_id.h"
  7. #include "components/services/app_service/public/cpp/app_registry_cache.h"
  8. namespace {
  9. const std::string kTestUuidBrowser = "040b6112-67f2-4d3c-8ba8-53a117272eba";
  10. const std::string kBrowserUrl = "https://example.com/";
  11. const std::string kTestUuidChromeAndProgressive =
  12. "7f4b7ff0-970a-41bb-aa91-f6c3e2724207";
  13. const std::string kBrowserTemplateName = "BrowserTest";
  14. const std::string kChromePwaTemplateName = "ChromeAppTest";
  15. } // namespace
  16. namespace desks_storage::desk_test_util {
  17. constexpr char kTestChromeAppId[] = "test_chrome_app_id";
  18. constexpr char kTestPwaAppId[] = "test_pwa_app_id";
  19. constexpr char kTestSwaAppId[] = "test_swa_app_id";
  20. constexpr char kTestArcAppId[] = "test_arc_app_id";
  21. constexpr char kTestLacrosChromeAppId[] = "test_lacros_chrome_app_id";
  22. constexpr char kTestUnsupportedAppId[] = "test_unsupported_app_id";
  23. constexpr char kTestChromeAppId1[] = "test_chrome_app_1";
  24. constexpr char kTestPwaAppId1[] = "test_pwa_app_1";
  25. const std::string kValidPolicyTemplateBrowser =
  26. "{\"version\":1,\"uuid\":\"" + kTestUuidBrowser + "\",\"name\":\"" +
  27. kBrowserTemplateName +
  28. "\",\"created_time_usec\":\"1633535632\",\"updated_time_usec\": "
  29. "\"1633535632\",\"desk_type\":\"TEMPLATE\",\"desk\":{\"apps\":[{\"window_"
  30. "bound\":{\"left\":0,\"top\":1,\"height\":121,\"width\":120},\"window_"
  31. "state\":\"NORMAL\",\"z_index\":1,\"app_type\":\"BROWSER\",\"tabs\":[{"
  32. "\"url\":\"" +
  33. kBrowserUrl +
  34. "\"},{\"url\":\"https://"
  35. "example.com/"
  36. "2\"}],\"tab_groups\":[{\"first_"
  37. "index\":1,\"last_index\":2,\"title\":\"sample_tab_"
  38. "group\",\"color\":\"GREY\",\"is_collapsed\":false}],\"active_tab_index\":"
  39. "1,\"first_non_pinned_tab_index\":1,\"window_id\":0,"
  40. "\"display_id\":\"100\",\"event_flag\":0}]}}";
  41. const std::string kValidPolicyTemplateBrowserMinimized =
  42. "{\"version\":1,\"uuid\":\"" + kTestUuidBrowser + "\",\"name\":\"" +
  43. kBrowserTemplateName +
  44. "\",\"created_time_usec\":\"1633535632\",\"updated_time_usec\": "
  45. "\"1633535632\",\"desk_type\":\"TEMPLATE\",\"desk\":{\"apps\":[{\"window_"
  46. "bound\":{\"left\":0,\"top\":1,\"height\":121,\"width\":120},\"window_"
  47. "state\":\"MINIMIZED\",\"z_index\":1,\"app_type\":\"BROWSER\",\"tabs\":[{"
  48. "\"url\":\"" +
  49. kBrowserUrl +
  50. "\"},{\"url\":\"https://"
  51. "example.com/"
  52. "2\"}],\"tab_groups\":[{\"first_"
  53. "index\":1,\"last_index\":2,\"title\":\"sample_tab_"
  54. "group\",\"color\":\"GREY\",\"is_collapsed\":false}],\"active_tab_index\":"
  55. "1,\"first_non_pinned_tab_index\":1,\"window_id\":0,"
  56. "\"display_id\":\"100\",\"event_flag\":0,\"pre_minimized_window_state\":"
  57. "\"NORMAL\"}]}}";
  58. const std::string kValidPolicyTemplateChromeAndProgressive =
  59. "{\"version\":1,\"uuid\":\"" + kTestUuidChromeAndProgressive +
  60. "\",\"name\":\"" + kChromePwaTemplateName +
  61. "\",\"created_time_usec\":\"1633535632000\",\"updated_time_usec\": "
  62. "\"1633535632\",\"desk_type\":\"SAVE_AND_RECALL\",\"desk\":{\"apps\":[{"
  63. "\"window_"
  64. "bound\":{"
  65. "\"left\":200,\"top\":200,\"height\":1000,\"width\":1000},\"window_state\":"
  66. "\"PRIMARY_SNAPPED\",\"z_index\":2,\"app_type\":\"CHROME_APP\",\"app_id\":"
  67. "\"" +
  68. desk_test_util::kTestChromeAppId1 +
  69. "\",\"window_id\":0,\"display_id\":\"100\",\"event_flag\":0, "
  70. "\"snap_percent\":75},{\"window_"
  71. "bound\":{\"left\":0,\"top\":0,\"height\":120,\"width\":120},\"window_"
  72. "state\":\"NORMAL\",\"z_index\":1,\"app_type\":\"CHROME_APP\",\"app_id\":"
  73. "\"" +
  74. desk_test_util::kTestPwaAppId1 +
  75. "\",\"window_id\":1,\"display_id\":"
  76. "\"100\",\"event_flag\":0}]}}";
  77. const std::string kPolicyTemplateWithoutType =
  78. "{\"version\":1,\"uuid\":\"" + kTestUuidBrowser + "\",\"name\":\"" +
  79. kBrowserTemplateName +
  80. "\",\"created_time_usec\":\"1633535632\",\"updated_time_usec\": "
  81. "\"1633535632\",\"desk\":{\"apps\":[{\"window_"
  82. "bound\":{\"left\":0,\"top\":1,\"height\":121,\"width\":120},\"window_"
  83. "state\":\"NORMAL\",\"z_index\":1,\"app_type\":\"BROWSER\",\"tabs\":[{"
  84. "\"url\":\"" +
  85. kBrowserUrl + "\"},{\"url\":\"" + kBrowserUrl +
  86. "\"}],\"tab_groups\":[{\"first_"
  87. "index\":1,\"last_index\":2,\"title\":\"sample_tab_"
  88. "group\",\"color\":\"GREY\",\"is_collapsed\":false}],\"active_tab_index\":"
  89. "1,\"first_non_pinned_tab_index\":1,\"window_id\":0,"
  90. "\"display_id\":\"100\",\"event_flag\":0}]}}";
  91. // Populates the given cache with test app information.
  92. void PopulateAppRegistryCache(AccountId account_id,
  93. apps::AppRegistryCache* cache);
  94. void AddAppIdToAppRegistryCache(AccountId account_id,
  95. apps::AppRegistryCache* cache,
  96. const char* app_id);
  97. } // namespace desks_storage::desk_test_util
  98. #endif // COMPONENTS_DESKS_STORAGE_CORE_DESK_TEST_UTIL_H_