Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(395)

Unified Diff: services/ui/ws/test_utils.cc

Issue 2904993003: chromeos: changes how DisplayManagerObservers are notified (Closed)
Patch Set: cleanup Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « services/ui/ws/test_utils.h ('k') | services/ui/ws/user_display_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/ui/ws/test_utils.cc
diff --git a/services/ui/ws/test_utils.cc b/services/ui/ws/test_utils.cc
index f9735fe32b1b7f9c1befa4ccab110e3945a27829..9ee891fe11356d1ed71c2c95d3dc589b46e68147 100644
--- a/services/ui/ws/test_utils.cc
+++ b/services/ui/ws/test_utils.cc
@@ -7,11 +7,13 @@
#include <utility>
#include "base/memory/ptr_util.h"
+#include "base/strings/string_number_conversions.h"
#include "cc/output/copy_output_request.h"
#include "gpu/ipc/client/gpu_channel_host.h"
#include "services/service_manager/public/interfaces/connector.mojom.h"
#include "services/ui/public/interfaces/cursor/cursor.mojom.h"
#include "services/ui/ws/display_binding.h"
+#include "services/ui/ws/display_creation_config.h"
#include "services/ui/ws/display_manager.h"
#include "services/ui/ws/window_manager_access_policy.h"
#include "services/ui/ws/window_manager_window_tree_factory.h"
@@ -524,6 +526,17 @@ bool TestWindowServerDelegate::IsTestConfig() const {
return true;
}
+void TestWindowServerDelegate::OnWillCreateTreeForWindowManager(
+ bool automatically_create_display_roots) {
+ if (window_server_->display_creation_config() !=
+ DisplayCreationConfig::UNKNOWN) {
+ return;
+ }
+ window_server_->SetDisplayCreationConfig(
+ automatically_create_display_roots ? DisplayCreationConfig::AUTOMATIC
+ : DisplayCreationConfig::MANUAL);
+}
+
// WindowServerTestHelper ---------------------------------------------------
WindowServerTestHelper::WindowServerTestHelper()
@@ -621,6 +634,42 @@ void WindowEventTargetingHelper::SetTaskRunner(
// ----------------------------------------------------------------------------
+TestDisplayManagerObserver::TestDisplayManagerObserver() : binding_(this) {}
+
+TestDisplayManagerObserver::~TestDisplayManagerObserver() = default;
+
+mojom::DisplayManagerObserverPtr TestDisplayManagerObserver::GetPtr() {
+ return binding_.CreateInterfacePtrAndBind();
+}
+
+std::string TestDisplayManagerObserver::GetAndClearObserverCalls() {
+ std::string result;
+ std::swap(observer_calls_, result);
+ return result;
+}
+
+std::string TestDisplayManagerObserver::DisplayIdsToString(
+ const std::vector<mojom::WsDisplayPtr>& wm_displays) {
+ std::string display_ids;
+ for (const auto& wm_display : wm_displays) {
+ if (!display_ids.empty())
+ display_ids += " ";
+ display_ids += base::Int64ToString(wm_display->display.id());
+ }
+ return display_ids;
+}
+
+void TestDisplayManagerObserver::OnDisplaysChanged(
+ std::vector<mojom::WsDisplayPtr> displays,
+ int64_t primary_display_id,
+ int64_t internal_display_id) {
+ if (!observer_calls_.empty())
+ observer_calls_ += "\n";
+ observer_calls_ += "OnDisplaysChanged " + DisplayIdsToString(displays);
+}
+
+// -----------------------------------------------------------------------------
+
void AddWindowManager(WindowServer* window_server,
const UserId& user_id,
bool automatically_create_display_roots) {
« no previous file with comments | « services/ui/ws/test_utils.h ('k') | services/ui/ws/user_display_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698