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

Unified Diff: ui/views/mus/window_tree_host_mus.cc

Issue 2409053002: mash: Use null AcceleratedWidget for widgets in tests (Closed)
Patch Set: . Created 4 years, 2 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 | « mash/test/mash_test_suite.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/mus/window_tree_host_mus.cc
diff --git a/ui/views/mus/window_tree_host_mus.cc b/ui/views/mus/window_tree_host_mus.cc
index caed894310e48e65017d0b3d2b56882ca5b1a22f..06f240a8f5e1c71534ee5e69164268c7edcaddb6 100644
--- a/ui/views/mus/window_tree_host_mus.cc
+++ b/ui/views/mus/window_tree_host_mus.cc
@@ -6,6 +6,7 @@
#include "base/memory/ptr_util.h"
#include "services/ui/public/cpp/window.h"
+#include "ui/aura/env.h"
#include "ui/aura/window.h"
#include "ui/aura/window_event_dispatcher.h"
#include "ui/events/event.h"
@@ -17,6 +18,11 @@ namespace views {
namespace {
static uint32_t accelerated_widget_count = 1;
+
+bool IsUsingTestContext() {
+ return aura::Env::GetInstance()->context_factory()->DoesCreateTestContexts();
+}
+
}
////////////////////////////////////////////////////////////////////////////////
@@ -25,16 +31,21 @@ static uint32_t accelerated_widget_count = 1;
WindowTreeHostMus::WindowTreeHostMus(NativeWidgetMus* native_widget,
ui::Window* window)
: native_widget_(native_widget) {
-// We need accelerated widget numbers to be different for each
-// window and fit in the smallest sizeof(AcceleratedWidget) uint32_t
-// has this property.
+ gfx::AcceleratedWidget accelerated_widget;
+ if (IsUsingTestContext()) {
+ accelerated_widget = gfx::kNullAcceleratedWidget;
+ } else {
+ // We need accelerated widget numbers to be different for each
+ // window and fit in the smallest sizeof(AcceleratedWidget) uint32_t
+ // has this property.
#if defined(OS_WIN) || defined(OS_ANDROID)
- gfx::AcceleratedWidget accelerated_widget =
- reinterpret_cast<gfx::AcceleratedWidget>(accelerated_widget_count++);
+ accelerated_widget =
+ reinterpret_cast<gfx::AcceleratedWidget>(accelerated_widget_count++);
#else
- gfx::AcceleratedWidget accelerated_widget =
- static_cast<gfx::AcceleratedWidget>(accelerated_widget_count++);
+ accelerated_widget =
+ static_cast<gfx::AcceleratedWidget>(accelerated_widget_count++);
#endif
+ }
// TODO(markdittmer): Use correct device-scale-factor from |window|.
OnAcceleratedWidgetAvailable(accelerated_widget, 1.f);
« no previous file with comments | « mash/test/mash_test_suite.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698