| OLD | NEW |
| 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 "ash/wm/window_positioner.h" | 6 #include "ash/wm/window_positioner.h" |
| 7 #include "ash/wm/window_util.h" | 7 #include "ash/wm/window_util.h" |
| 8 #include "components/exo/buffer.h" | 8 #include "components/exo/buffer.h" |
| 9 #include "components/exo/shell_surface.h" | 9 #include "components/exo/shell_surface.h" |
| 10 #include "components/exo/surface.h" | 10 #include "components/exo/surface.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 MOCK_METHOD3(OnTouchMotion, void(base::TimeDelta, int, const gfx::Point&)); | 35 MOCK_METHOD3(OnTouchMotion, void(base::TimeDelta, int, const gfx::Point&)); |
| 36 MOCK_METHOD0(OnTouchCancel, void()); | 36 MOCK_METHOD0(OnTouchCancel, void()); |
| 37 }; | 37 }; |
| 38 | 38 |
| 39 TEST_F(TouchTest, OnTouchDown) { | 39 TEST_F(TouchTest, OnTouchDown) { |
| 40 ash::WindowPositioner::DisableAutoPositioning(true); | 40 ash::WindowPositioner::DisableAutoPositioning(true); |
| 41 | 41 |
| 42 scoped_ptr<Surface> bottom_surface(new Surface); | 42 scoped_ptr<Surface> bottom_surface(new Surface); |
| 43 scoped_ptr<ShellSurface> bottom_shell_surface( | 43 scoped_ptr<ShellSurface> bottom_shell_surface( |
| 44 new ShellSurface(bottom_surface.get())); | 44 new ShellSurface(bottom_surface.get())); |
| 45 bottom_shell_surface->Init(); | |
| 46 gfx::Size bottom_buffer_size(10, 10); | 45 gfx::Size bottom_buffer_size(10, 10); |
| 47 scoped_ptr<Buffer> bottom_buffer( | 46 scoped_ptr<Buffer> bottom_buffer( |
| 48 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(bottom_buffer_size), | 47 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(bottom_buffer_size), |
| 49 GL_TEXTURE_2D)); | 48 GL_TEXTURE_2D)); |
| 50 bottom_surface->Attach(bottom_buffer.get()); | 49 bottom_surface->Attach(bottom_buffer.get()); |
| 51 bottom_surface->Commit(); | 50 bottom_surface->Commit(); |
| 52 ash::wm::CenterWindow(bottom_shell_surface->GetWidget()->GetNativeWindow()); | 51 ash::wm::CenterWindow(bottom_shell_surface->GetWidget()->GetNativeWindow()); |
| 53 | 52 |
| 54 scoped_ptr<Surface> top_surface(new Surface); | 53 scoped_ptr<Surface> top_surface(new Surface); |
| 55 scoped_ptr<ShellSurface> top_shell_surface( | 54 scoped_ptr<ShellSurface> top_shell_surface( |
| 56 new ShellSurface(top_surface.get())); | 55 new ShellSurface(top_surface.get())); |
| 57 top_shell_surface->Init(); | |
| 58 gfx::Size top_buffer_size(8, 8); | 56 gfx::Size top_buffer_size(8, 8); |
| 59 scoped_ptr<Buffer> top_buffer( | 57 scoped_ptr<Buffer> top_buffer( |
| 60 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(top_buffer_size), | 58 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(top_buffer_size), |
| 61 GL_TEXTURE_2D)); | 59 GL_TEXTURE_2D)); |
| 62 top_surface->Attach(top_buffer.get()); | 60 top_surface->Attach(top_buffer.get()); |
| 63 top_surface->Commit(); | 61 top_surface->Commit(); |
| 64 ash::wm::CenterWindow(top_shell_surface->GetWidget()->GetNativeWindow()); | 62 ash::wm::CenterWindow(top_shell_surface->GetWidget()->GetNativeWindow()); |
| 65 | 63 |
| 66 MockTouchDelegate delegate; | 64 MockTouchDelegate delegate; |
| 67 scoped_ptr<Touch> touch(new Touch(&delegate)); | 65 scoped_ptr<Touch> touch(new Touch(&delegate)); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 82 generator.set_current_location(bottom_surface->GetBoundsInScreen().origin()); | 80 generator.set_current_location(bottom_surface->GetBoundsInScreen().origin()); |
| 83 generator.PressTouchId(2); | 81 generator.PressTouchId(2); |
| 84 | 82 |
| 85 EXPECT_CALL(delegate, OnTouchDestroying(touch.get())); | 83 EXPECT_CALL(delegate, OnTouchDestroying(touch.get())); |
| 86 touch.reset(); | 84 touch.reset(); |
| 87 } | 85 } |
| 88 | 86 |
| 89 TEST_F(TouchTest, OnTouchUp) { | 87 TEST_F(TouchTest, OnTouchUp) { |
| 90 scoped_ptr<Surface> surface(new Surface); | 88 scoped_ptr<Surface> surface(new Surface); |
| 91 scoped_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get())); | 89 scoped_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get())); |
| 92 shell_surface->Init(); | |
| 93 gfx::Size buffer_size(10, 10); | 90 gfx::Size buffer_size(10, 10); |
| 94 scoped_ptr<Buffer> buffer(new Buffer( | 91 scoped_ptr<Buffer> buffer(new Buffer( |
| 95 exo_test_helper()->CreateGpuMemoryBuffer(buffer_size), GL_TEXTURE_2D)); | 92 exo_test_helper()->CreateGpuMemoryBuffer(buffer_size), GL_TEXTURE_2D)); |
| 96 surface->Attach(buffer.get()); | 93 surface->Attach(buffer.get()); |
| 97 surface->Commit(); | 94 surface->Commit(); |
| 98 | 95 |
| 99 MockTouchDelegate delegate; | 96 MockTouchDelegate delegate; |
| 100 scoped_ptr<Touch> touch(new Touch(&delegate)); | 97 scoped_ptr<Touch> touch(new Touch(&delegate)); |
| 101 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow()); | 98 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow()); |
| 102 | 99 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 114 EXPECT_CALL(delegate, OnTouchUp(testing::_, 2)); | 111 EXPECT_CALL(delegate, OnTouchUp(testing::_, 2)); |
| 115 generator.ReleaseTouchId(2); | 112 generator.ReleaseTouchId(2); |
| 116 | 113 |
| 117 EXPECT_CALL(delegate, OnTouchDestroying(touch.get())); | 114 EXPECT_CALL(delegate, OnTouchDestroying(touch.get())); |
| 118 touch.reset(); | 115 touch.reset(); |
| 119 } | 116 } |
| 120 | 117 |
| 121 TEST_F(TouchTest, OnTouchMotion) { | 118 TEST_F(TouchTest, OnTouchMotion) { |
| 122 scoped_ptr<Surface> surface(new Surface); | 119 scoped_ptr<Surface> surface(new Surface); |
| 123 scoped_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get())); | 120 scoped_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get())); |
| 124 shell_surface->Init(); | |
| 125 gfx::Size buffer_size(10, 10); | 121 gfx::Size buffer_size(10, 10); |
| 126 scoped_ptr<Buffer> buffer(new Buffer( | 122 scoped_ptr<Buffer> buffer(new Buffer( |
| 127 exo_test_helper()->CreateGpuMemoryBuffer(buffer_size), GL_TEXTURE_2D)); | 123 exo_test_helper()->CreateGpuMemoryBuffer(buffer_size), GL_TEXTURE_2D)); |
| 128 surface->Attach(buffer.get()); | 124 surface->Attach(buffer.get()); |
| 129 surface->Commit(); | 125 surface->Commit(); |
| 130 | 126 |
| 131 MockTouchDelegate delegate; | 127 MockTouchDelegate delegate; |
| 132 scoped_ptr<Touch> touch(new Touch(&delegate)); | 128 scoped_ptr<Touch> touch(new Touch(&delegate)); |
| 133 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow()); | 129 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow()); |
| 134 | 130 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 152 generator.set_current_location(surface->GetBoundsInScreen().origin()); | 148 generator.set_current_location(surface->GetBoundsInScreen().origin()); |
| 153 generator.PressMoveAndReleaseTouchBy(100, 100); | 149 generator.PressMoveAndReleaseTouchBy(100, 100); |
| 154 | 150 |
| 155 EXPECT_CALL(delegate, OnTouchDestroying(touch.get())); | 151 EXPECT_CALL(delegate, OnTouchDestroying(touch.get())); |
| 156 touch.reset(); | 152 touch.reset(); |
| 157 } | 153 } |
| 158 | 154 |
| 159 TEST_F(TouchTest, OnTouchCancel) { | 155 TEST_F(TouchTest, OnTouchCancel) { |
| 160 scoped_ptr<Surface> surface(new Surface); | 156 scoped_ptr<Surface> surface(new Surface); |
| 161 scoped_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get())); | 157 scoped_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get())); |
| 162 shell_surface->Init(); | |
| 163 gfx::Size buffer_size(10, 10); | 158 gfx::Size buffer_size(10, 10); |
| 164 scoped_ptr<Buffer> buffer(new Buffer( | 159 scoped_ptr<Buffer> buffer(new Buffer( |
| 165 exo_test_helper()->CreateGpuMemoryBuffer(buffer_size), GL_TEXTURE_2D)); | 160 exo_test_helper()->CreateGpuMemoryBuffer(buffer_size), GL_TEXTURE_2D)); |
| 166 surface->Attach(buffer.get()); | 161 surface->Attach(buffer.get()); |
| 167 surface->Commit(); | 162 surface->Commit(); |
| 168 | 163 |
| 169 MockTouchDelegate delegate; | 164 MockTouchDelegate delegate; |
| 170 scoped_ptr<Touch> touch(new Touch(&delegate)); | 165 scoped_ptr<Touch> touch(new Touch(&delegate)); |
| 171 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow()); | 166 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow()); |
| 172 | 167 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 184 ui::TouchEvent cancel_event(ui::ET_TOUCH_CANCELLED, gfx::Point(), 1, | 179 ui::TouchEvent cancel_event(ui::ET_TOUCH_CANCELLED, gfx::Point(), 1, |
| 185 generator.Now()); | 180 generator.Now()); |
| 186 generator.Dispatch(&cancel_event); | 181 generator.Dispatch(&cancel_event); |
| 187 | 182 |
| 188 EXPECT_CALL(delegate, OnTouchDestroying(touch.get())); | 183 EXPECT_CALL(delegate, OnTouchDestroying(touch.get())); |
| 189 touch.reset(); | 184 touch.reset(); |
| 190 } | 185 } |
| 191 | 186 |
| 192 } // namespace | 187 } // namespace |
| 193 } // namespace exo | 188 } // namespace exo |
| OLD | NEW |