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

Side by Side Diff: services/ui/ws/test_utils.cc

Issue 2189893004: Unify display ids between Display and PlatformDisplay. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move id into PlatformDisplay and fix tests. Created 4 years, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "services/ui/ws/test_utils.h" 5 #include "services/ui/ws/test_utils.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "cc/output/copy_output_request.h" 10 #include "cc/output/copy_output_request.h"
11 #include "services/shell/public/interfaces/connector.mojom.h" 11 #include "services/shell/public/interfaces/connector.mojom.h"
12 #include "services/ui/surfaces/surfaces_state.h" 12 #include "services/ui/surfaces/surfaces_state.h"
13 #include "services/ui/ws/display_binding.h" 13 #include "services/ui/ws/display_binding.h"
14 #include "services/ui/ws/display_manager.h" 14 #include "services/ui/ws/display_manager.h"
15 #include "services/ui/ws/platform_display_init_params.h" 15 #include "services/ui/ws/platform_display_init_params.h"
16 #include "services/ui/ws/server_window_surface_manager_test_api.h" 16 #include "services/ui/ws/server_window_surface_manager_test_api.h"
17 #include "services/ui/ws/window_manager_access_policy.h" 17 #include "services/ui/ws/window_manager_access_policy.h"
18 #include "services/ui/ws/window_manager_window_tree_factory.h" 18 #include "services/ui/ws/window_manager_window_tree_factory.h"
19 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
20 20
21 namespace ui { 21 namespace ui {
22 namespace ws { 22 namespace ws {
23 namespace test { 23 namespace test {
24 namespace { 24 namespace {
25 25
26 // ----------------------------------------------------------------------------- 26 // -----------------------------------------------------------------------------
27 // Empty implementation of PlatformDisplay. 27 // Empty implementation of PlatformDisplay.
28 class TestPlatformDisplay : public PlatformDisplay { 28 class TestPlatformDisplay : public PlatformDisplay {
29 public: 29 public:
30 explicit TestPlatformDisplay(int32_t* cursor_id_storage) 30 explicit TestPlatformDisplay(int64_t id, int32_t* cursor_id_storage)
31 : cursor_id_storage_(cursor_id_storage) { 31 : PlatformDisplay(id), cursor_id_storage_(cursor_id_storage) {
32 display_metrics_.bounds = gfx::Rect(0, 0, 400, 300); 32 display_metrics_.bounds = gfx::Rect(0, 0, 400, 300);
33 display_metrics_.device_scale_factor = 1.f; 33 display_metrics_.device_scale_factor = 1.f;
34 } 34 }
35 ~TestPlatformDisplay() override {} 35 ~TestPlatformDisplay() override {}
36 36
37 // PlatformDisplay: 37 // PlatformDisplay:
38 void Init(PlatformDisplayDelegate* delegate) override { 38 void Init(PlatformDisplayDelegate* delegate) override {
39 // It is necessary to tell the delegate about the ViewportMetrics to make 39 // It is necessary to tell the delegate about the ViewportMetrics to make
40 // sure that the DisplayBinding is correctly initialized (and a root-window 40 // sure that the DisplayBinding is correctly initialized (and a root-window
41 // is created). 41 // is created).
(...skipping 10 matching lines...) Expand all
52 return ::display::Display::Rotation::ROTATE_0; 52 return ::display::Display::Rotation::ROTATE_0;
53 } 53 }
54 float GetDeviceScaleFactor() override { 54 float GetDeviceScaleFactor() override {
55 return display_metrics_.device_scale_factor; 55 return display_metrics_.device_scale_factor;
56 } 56 }
57 void UpdateTextInputState(const ui::TextInputState& state) override {} 57 void UpdateTextInputState(const ui::TextInputState& state) override {}
58 void SetImeVisibility(bool visible) override {} 58 void SetImeVisibility(bool visible) override {}
59 bool IsFramePending() const override { return false; } 59 bool IsFramePending() const override { return false; }
60 void RequestCopyOfOutput( 60 void RequestCopyOfOutput(
61 std::unique_ptr<cc::CopyOutputRequest> output_request) override {} 61 std::unique_ptr<cc::CopyOutputRequest> output_request) override {}
62 int64_t GetDisplayId() const override { return 1; }
63 gfx::Rect GetBounds() const override { return display_metrics_.bounds; } 62 gfx::Rect GetBounds() const override { return display_metrics_.bounds; }
64 63
65 private: 64 private:
66 ViewportMetrics display_metrics_; 65 ViewportMetrics display_metrics_;
67 66
68 int32_t* cursor_id_storage_; 67 int32_t* cursor_id_storage_;
69 68
70 DISALLOW_COPY_AND_ASSIGN(TestPlatformDisplay); 69 DISALLOW_COPY_AND_ASSIGN(TestPlatformDisplay);
71 }; 70 };
72 71
(...skipping 30 matching lines...) Expand all
103 102
104 // TestPlatformDisplayFactory ------------------------------------------------- 103 // TestPlatformDisplayFactory -------------------------------------------------
105 104
106 TestPlatformDisplayFactory::TestPlatformDisplayFactory( 105 TestPlatformDisplayFactory::TestPlatformDisplayFactory(
107 int32_t* cursor_id_storage) 106 int32_t* cursor_id_storage)
108 : cursor_id_storage_(cursor_id_storage) {} 107 : cursor_id_storage_(cursor_id_storage) {}
109 108
110 TestPlatformDisplayFactory::~TestPlatformDisplayFactory() {} 109 TestPlatformDisplayFactory::~TestPlatformDisplayFactory() {}
111 110
112 PlatformDisplay* TestPlatformDisplayFactory::CreatePlatformDisplay() { 111 PlatformDisplay* TestPlatformDisplayFactory::CreatePlatformDisplay() {
113 return new TestPlatformDisplay(cursor_id_storage_); 112 return new TestPlatformDisplay(next_display_id++, cursor_id_storage_);
114 } 113 }
115 114
116 // TestFrameGeneratorDelegate ------------------------------------------------- 115 // TestFrameGeneratorDelegate -------------------------------------------------
117 116
118 TestFrameGeneratorDelegate::TestFrameGeneratorDelegate( 117 TestFrameGeneratorDelegate::TestFrameGeneratorDelegate(
119 std::unique_ptr<ServerWindow> root) 118 std::unique_ptr<ServerWindow> root)
120 : root_(std::move(root)) {} 119 : root_(std::move(root)) {}
121 120
122 TestFrameGeneratorDelegate::~TestFrameGeneratorDelegate() {} 121 TestFrameGeneratorDelegate::~TestFrameGeneratorDelegate() {}
123 122
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 return nullptr; 522 return nullptr;
524 if (!tree->AddWindow(parent_client_id, client_window_id)) 523 if (!tree->AddWindow(parent_client_id, client_window_id))
525 return nullptr; 524 return nullptr;
526 *client_id = client_window_id; 525 *client_id = client_window_id;
527 return tree->GetWindowByClientId(client_window_id); 526 return tree->GetWindowByClientId(client_window_id);
528 } 527 }
529 528
530 } // namespace test 529 } // namespace test
531 } // namespace ws 530 } // namespace ws
532 } // namespace ui 531 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698