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

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

Issue 1580033004: exo: Improve Maximize and Fullscreen support for ShellSurfaces. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add TODO Created 4 years, 11 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->SetToplevel(); 42 shell_surface->Init();
43 gfx::Size buffer_size(10, 10); 43 gfx::Size buffer_size(10, 10);
44 scoped_ptr<Buffer> buffer(new Buffer( 44 scoped_ptr<Buffer> buffer(new Buffer(
45 exo_test_helper()->CreateGpuMemoryBuffer(buffer_size), GL_TEXTURE_2D)); 45 exo_test_helper()->CreateGpuMemoryBuffer(buffer_size), GL_TEXTURE_2D));
46 surface->Attach(buffer.get()); 46 surface->Attach(buffer.get());
47 surface->Commit(); 47 surface->Commit();
48 48
49 MockKeyboardDelegate delegate; 49 MockKeyboardDelegate delegate;
50 scoped_ptr<Keyboard> keyboard(new Keyboard(&delegate)); 50 scoped_ptr<Keyboard> keyboard(new Keyboard(&delegate));
51 51
52 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow()); 52 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow());
(...skipping 18 matching lines...) Expand all
71 focus_client->FocusWindow(nullptr); 71 focus_client->FocusWindow(nullptr);
72 focus_client->FocusWindow(surface.get()); 72 focus_client->FocusWindow(surface.get());
73 73
74 EXPECT_CALL(delegate, OnKeyboardDestroying(keyboard.get())); 74 EXPECT_CALL(delegate, OnKeyboardDestroying(keyboard.get()));
75 keyboard.reset(); 75 keyboard.reset();
76 } 76 }
77 77
78 TEST_F(KeyboardTest, OnKeyboardLeave) { 78 TEST_F(KeyboardTest, OnKeyboardLeave) {
79 scoped_ptr<Surface> surface(new Surface); 79 scoped_ptr<Surface> surface(new Surface);
80 scoped_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get())); 80 scoped_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get()));
81 shell_surface->SetToplevel(); 81 shell_surface->Init();
82 gfx::Size buffer_size(10, 10); 82 gfx::Size buffer_size(10, 10);
83 scoped_ptr<Buffer> buffer(new Buffer( 83 scoped_ptr<Buffer> buffer(new Buffer(
84 exo_test_helper()->CreateGpuMemoryBuffer(buffer_size), GL_TEXTURE_2D)); 84 exo_test_helper()->CreateGpuMemoryBuffer(buffer_size), GL_TEXTURE_2D));
85 surface->Attach(buffer.get()); 85 surface->Attach(buffer.get());
86 surface->Commit(); 86 surface->Commit();
87 87
88 MockKeyboardDelegate delegate; 88 MockKeyboardDelegate delegate;
89 scoped_ptr<Keyboard> keyboard(new Keyboard(&delegate)); 89 scoped_ptr<Keyboard> keyboard(new Keyboard(&delegate));
90 90
91 aura::client::FocusClient* focus_client = 91 aura::client::FocusClient* focus_client =
92 aura::client::GetFocusClient(ash::Shell::GetPrimaryRootWindow()); 92 aura::client::GetFocusClient(ash::Shell::GetPrimaryRootWindow());
93 EXPECT_CALL(delegate, CanAcceptKeyboardEventsForSurface(surface.get())) 93 EXPECT_CALL(delegate, CanAcceptKeyboardEventsForSurface(surface.get()))
94 .WillOnce(testing::Return(true)); 94 .WillOnce(testing::Return(true));
95 EXPECT_CALL(delegate, OnKeyboardModifiers(0)); 95 EXPECT_CALL(delegate, OnKeyboardModifiers(0));
96 EXPECT_CALL(delegate, 96 EXPECT_CALL(delegate,
97 OnKeyboardEnter(surface.get(), std::vector<ui::DomCode>())); 97 OnKeyboardEnter(surface.get(), std::vector<ui::DomCode>()));
98 focus_client->FocusWindow(surface.get()); 98 focus_client->FocusWindow(surface.get());
99 99
100 EXPECT_CALL(delegate, OnKeyboardLeave(surface.get())); 100 EXPECT_CALL(delegate, OnKeyboardLeave(surface.get()));
101 focus_client->FocusWindow(nullptr); 101 focus_client->FocusWindow(nullptr);
102 102
103 EXPECT_CALL(delegate, OnKeyboardDestroying(keyboard.get())); 103 EXPECT_CALL(delegate, OnKeyboardDestroying(keyboard.get()));
104 keyboard.reset(); 104 keyboard.reset();
105 } 105 }
106 106
107 TEST_F(KeyboardTest, OnKeyboardKey) { 107 TEST_F(KeyboardTest, OnKeyboardKey) {
108 scoped_ptr<Surface> surface(new Surface); 108 scoped_ptr<Surface> surface(new Surface);
109 scoped_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get())); 109 scoped_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get()));
110 shell_surface->SetToplevel(); 110 shell_surface->Init();
111 gfx::Size buffer_size(10, 10); 111 gfx::Size buffer_size(10, 10);
112 scoped_ptr<Buffer> buffer(new Buffer( 112 scoped_ptr<Buffer> buffer(new Buffer(
113 exo_test_helper()->CreateGpuMemoryBuffer(buffer_size), GL_TEXTURE_2D)); 113 exo_test_helper()->CreateGpuMemoryBuffer(buffer_size), GL_TEXTURE_2D));
114 surface->Attach(buffer.get()); 114 surface->Attach(buffer.get());
115 surface->Commit(); 115 surface->Commit();
116 116
117 MockKeyboardDelegate delegate; 117 MockKeyboardDelegate delegate;
118 scoped_ptr<Keyboard> keyboard(new Keyboard(&delegate)); 118 scoped_ptr<Keyboard> keyboard(new Keyboard(&delegate));
119 119
120 aura::client::FocusClient* focus_client = 120 aura::client::FocusClient* focus_client =
(...skipping 17 matching lines...) Expand all
138 generator.ReleaseKey(ui::VKEY_A, 0); 138 generator.ReleaseKey(ui::VKEY_A, 0);
139 generator.ReleaseKey(ui::VKEY_A, 0); 139 generator.ReleaseKey(ui::VKEY_A, 0);
140 140
141 EXPECT_CALL(delegate, OnKeyboardDestroying(keyboard.get())); 141 EXPECT_CALL(delegate, OnKeyboardDestroying(keyboard.get()));
142 keyboard.reset(); 142 keyboard.reset();
143 } 143 }
144 144
145 TEST_F(KeyboardTest, OnKeyboardModifiers) { 145 TEST_F(KeyboardTest, OnKeyboardModifiers) {
146 scoped_ptr<Surface> surface(new Surface); 146 scoped_ptr<Surface> surface(new Surface);
147 scoped_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get())); 147 scoped_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get()));
148 shell_surface->SetToplevel(); 148 shell_surface->Init();
149 gfx::Size buffer_size(10, 10); 149 gfx::Size buffer_size(10, 10);
150 scoped_ptr<Buffer> buffer(new Buffer( 150 scoped_ptr<Buffer> buffer(new Buffer(
151 exo_test_helper()->CreateGpuMemoryBuffer(buffer_size), GL_TEXTURE_2D)); 151 exo_test_helper()->CreateGpuMemoryBuffer(buffer_size), GL_TEXTURE_2D));
152 surface->Attach(buffer.get()); 152 surface->Attach(buffer.get());
153 surface->Commit(); 153 surface->Commit();
154 154
155 MockKeyboardDelegate delegate; 155 MockKeyboardDelegate delegate;
156 scoped_ptr<Keyboard> keyboard(new Keyboard(&delegate)); 156 scoped_ptr<Keyboard> keyboard(new Keyboard(&delegate));
157 157
158 aura::client::FocusClient* focus_client = 158 aura::client::FocusClient* focus_client =
(...skipping 21 matching lines...) Expand all
180 EXPECT_CALL(delegate, OnKeyboardKey(testing::_, ui::DomCode::US_B, false)); 180 EXPECT_CALL(delegate, OnKeyboardKey(testing::_, ui::DomCode::US_B, false));
181 EXPECT_CALL(delegate, OnKeyboardModifiers(0)); 181 EXPECT_CALL(delegate, OnKeyboardModifiers(0));
182 generator.ReleaseKey(ui::VKEY_B, 0); 182 generator.ReleaseKey(ui::VKEY_B, 0);
183 183
184 EXPECT_CALL(delegate, OnKeyboardDestroying(keyboard.get())); 184 EXPECT_CALL(delegate, OnKeyboardDestroying(keyboard.get()));
185 keyboard.reset(); 185 keyboard.reset();
186 } 186 }
187 187
188 } // namespace 188 } // namespace
189 } // namespace exo 189 } // 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