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

Side by Side Diff: components/exo/keyboard_unittest.cc

Issue 1645043003: exo: Improve window placement. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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
« no previous file with comments | « no previous file | components/exo/pointer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "ash/shell.h" 5 #include "ash/shell.h"
6 #include "base/macros.h" 6 #include "base/macros.h"
7 #include "components/exo/buffer.h" 7 #include "components/exo/buffer.h"
8 #include "components/exo/keyboard.h" 8 #include "components/exo/keyboard.h"
9 #include "components/exo/keyboard_delegate.h" 9 #include "components/exo/keyboard_delegate.h"
10 #include "components/exo/shell_surface.h" 10 #include "components/exo/shell_surface.h"
(...skipping 21 matching lines...) Expand all
32 MOCK_METHOD2(OnKeyboardEnter, 32 MOCK_METHOD2(OnKeyboardEnter,
33 void(Surface*, const std::vector<ui::DomCode>&)); 33 void(Surface*, const std::vector<ui::DomCode>&));
34 MOCK_METHOD1(OnKeyboardLeave, void(Surface*)); 34 MOCK_METHOD1(OnKeyboardLeave, void(Surface*));
35 MOCK_METHOD3(OnKeyboardKey, void(base::TimeDelta, ui::DomCode, bool)); 35 MOCK_METHOD3(OnKeyboardKey, void(base::TimeDelta, ui::DomCode, bool));
36 MOCK_METHOD1(OnKeyboardModifiers, void(int)); 36 MOCK_METHOD1(OnKeyboardModifiers, void(int));
37 }; 37 };
38 38
39 TEST_F(KeyboardTest, OnKeyboardEnter) { 39 TEST_F(KeyboardTest, OnKeyboardEnter) {
40 scoped_ptr<Surface> surface(new Surface); 40 scoped_ptr<Surface> surface(new Surface);
41 scoped_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get())); 41 scoped_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get()));
42 shell_surface->Init();
43 gfx::Size buffer_size(10, 10); 42 gfx::Size buffer_size(10, 10);
44 scoped_ptr<Buffer> buffer(new Buffer( 43 scoped_ptr<Buffer> buffer(new Buffer(
45 exo_test_helper()->CreateGpuMemoryBuffer(buffer_size), GL_TEXTURE_2D)); 44 exo_test_helper()->CreateGpuMemoryBuffer(buffer_size), GL_TEXTURE_2D));
46 surface->Attach(buffer.get()); 45 surface->Attach(buffer.get());
47 surface->Commit(); 46 surface->Commit();
48 47
49 MockKeyboardDelegate delegate; 48 MockKeyboardDelegate delegate;
50 scoped_ptr<Keyboard> keyboard(new Keyboard(&delegate)); 49 scoped_ptr<Keyboard> keyboard(new Keyboard(&delegate));
51 50
52 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow()); 51 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow());
(...skipping 18 matching lines...) Expand all
71 focus_client->FocusWindow(nullptr); 70 focus_client->FocusWindow(nullptr);
72 focus_client->FocusWindow(surface.get()); 71 focus_client->FocusWindow(surface.get());
73 72
74 EXPECT_CALL(delegate, OnKeyboardDestroying(keyboard.get())); 73 EXPECT_CALL(delegate, OnKeyboardDestroying(keyboard.get()));
75 keyboard.reset(); 74 keyboard.reset();
76 } 75 }
77 76
78 TEST_F(KeyboardTest, OnKeyboardLeave) { 77 TEST_F(KeyboardTest, OnKeyboardLeave) {
79 scoped_ptr<Surface> surface(new Surface); 78 scoped_ptr<Surface> surface(new Surface);
80 scoped_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get())); 79 scoped_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get()));
81 shell_surface->Init();
82 gfx::Size buffer_size(10, 10); 80 gfx::Size buffer_size(10, 10);
83 scoped_ptr<Buffer> buffer(new Buffer( 81 scoped_ptr<Buffer> buffer(new Buffer(
84 exo_test_helper()->CreateGpuMemoryBuffer(buffer_size), GL_TEXTURE_2D)); 82 exo_test_helper()->CreateGpuMemoryBuffer(buffer_size), GL_TEXTURE_2D));
85 surface->Attach(buffer.get()); 83 surface->Attach(buffer.get());
86 surface->Commit(); 84 surface->Commit();
87 85
88 MockKeyboardDelegate delegate; 86 MockKeyboardDelegate delegate;
89 scoped_ptr<Keyboard> keyboard(new Keyboard(&delegate)); 87 scoped_ptr<Keyboard> keyboard(new Keyboard(&delegate));
90 88
91 aura::client::FocusClient* focus_client = 89 aura::client::FocusClient* focus_client =
92 aura::client::GetFocusClient(ash::Shell::GetPrimaryRootWindow()); 90 aura::client::GetFocusClient(ash::Shell::GetPrimaryRootWindow());
93 EXPECT_CALL(delegate, CanAcceptKeyboardEventsForSurface(surface.get())) 91 EXPECT_CALL(delegate, CanAcceptKeyboardEventsForSurface(surface.get()))
94 .WillOnce(testing::Return(true)); 92 .WillOnce(testing::Return(true));
95 EXPECT_CALL(delegate, OnKeyboardModifiers(0)); 93 EXPECT_CALL(delegate, OnKeyboardModifiers(0));
96 EXPECT_CALL(delegate, 94 EXPECT_CALL(delegate,
97 OnKeyboardEnter(surface.get(), std::vector<ui::DomCode>())); 95 OnKeyboardEnter(surface.get(), std::vector<ui::DomCode>()));
98 focus_client->FocusWindow(surface.get()); 96 focus_client->FocusWindow(surface.get());
99 97
100 EXPECT_CALL(delegate, OnKeyboardLeave(surface.get())); 98 EXPECT_CALL(delegate, OnKeyboardLeave(surface.get()));
101 focus_client->FocusWindow(nullptr); 99 focus_client->FocusWindow(nullptr);
102 100
103 EXPECT_CALL(delegate, OnKeyboardDestroying(keyboard.get())); 101 EXPECT_CALL(delegate, OnKeyboardDestroying(keyboard.get()));
104 keyboard.reset(); 102 keyboard.reset();
105 } 103 }
106 104
107 TEST_F(KeyboardTest, OnKeyboardKey) { 105 TEST_F(KeyboardTest, OnKeyboardKey) {
108 scoped_ptr<Surface> surface(new Surface); 106 scoped_ptr<Surface> surface(new Surface);
109 scoped_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get())); 107 scoped_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get()));
110 shell_surface->Init();
111 gfx::Size buffer_size(10, 10); 108 gfx::Size buffer_size(10, 10);
112 scoped_ptr<Buffer> buffer(new Buffer( 109 scoped_ptr<Buffer> buffer(new Buffer(
113 exo_test_helper()->CreateGpuMemoryBuffer(buffer_size), GL_TEXTURE_2D)); 110 exo_test_helper()->CreateGpuMemoryBuffer(buffer_size), GL_TEXTURE_2D));
114 surface->Attach(buffer.get()); 111 surface->Attach(buffer.get());
115 surface->Commit(); 112 surface->Commit();
116 113
117 MockKeyboardDelegate delegate; 114 MockKeyboardDelegate delegate;
118 scoped_ptr<Keyboard> keyboard(new Keyboard(&delegate)); 115 scoped_ptr<Keyboard> keyboard(new Keyboard(&delegate));
119 116
120 aura::client::FocusClient* focus_client = 117 aura::client::FocusClient* focus_client =
(...skipping 17 matching lines...) Expand all
138 generator.ReleaseKey(ui::VKEY_A, 0); 135 generator.ReleaseKey(ui::VKEY_A, 0);
139 generator.ReleaseKey(ui::VKEY_A, 0); 136 generator.ReleaseKey(ui::VKEY_A, 0);
140 137
141 EXPECT_CALL(delegate, OnKeyboardDestroying(keyboard.get())); 138 EXPECT_CALL(delegate, OnKeyboardDestroying(keyboard.get()));
142 keyboard.reset(); 139 keyboard.reset();
143 } 140 }
144 141
145 TEST_F(KeyboardTest, OnKeyboardModifiers) { 142 TEST_F(KeyboardTest, OnKeyboardModifiers) {
146 scoped_ptr<Surface> surface(new Surface); 143 scoped_ptr<Surface> surface(new Surface);
147 scoped_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get())); 144 scoped_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get()));
148 shell_surface->Init();
149 gfx::Size buffer_size(10, 10); 145 gfx::Size buffer_size(10, 10);
150 scoped_ptr<Buffer> buffer(new Buffer( 146 scoped_ptr<Buffer> buffer(new Buffer(
151 exo_test_helper()->CreateGpuMemoryBuffer(buffer_size), GL_TEXTURE_2D)); 147 exo_test_helper()->CreateGpuMemoryBuffer(buffer_size), GL_TEXTURE_2D));
152 surface->Attach(buffer.get()); 148 surface->Attach(buffer.get());
153 surface->Commit(); 149 surface->Commit();
154 150
155 MockKeyboardDelegate delegate; 151 MockKeyboardDelegate delegate;
156 scoped_ptr<Keyboard> keyboard(new Keyboard(&delegate)); 152 scoped_ptr<Keyboard> keyboard(new Keyboard(&delegate));
157 153
158 aura::client::FocusClient* focus_client = 154 aura::client::FocusClient* focus_client =
(...skipping 21 matching lines...) Expand all
180 EXPECT_CALL(delegate, OnKeyboardKey(testing::_, ui::DomCode::US_B, false)); 176 EXPECT_CALL(delegate, OnKeyboardKey(testing::_, ui::DomCode::US_B, false));
181 EXPECT_CALL(delegate, OnKeyboardModifiers(0)); 177 EXPECT_CALL(delegate, OnKeyboardModifiers(0));
182 generator.ReleaseKey(ui::VKEY_B, 0); 178 generator.ReleaseKey(ui::VKEY_B, 0);
183 179
184 EXPECT_CALL(delegate, OnKeyboardDestroying(keyboard.get())); 180 EXPECT_CALL(delegate, OnKeyboardDestroying(keyboard.get()));
185 keyboard.reset(); 181 keyboard.reset();
186 } 182 }
187 183
188 } // namespace 184 } // namespace
189 } // namespace exo 185 } // namespace exo
OLDNEW
« no previous file with comments | « no previous file | components/exo/pointer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698