OLD | NEW |
---|---|
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 "ui/aura/test/aura_test_base.h" | 5 #include "ui/aura/test/aura_test_base.h" |
6 #include "ui/aura/test/test_screen.h" | 6 #include "ui/aura/test/test_screen.h" |
7 #include "ui/aura/window.h" | 7 #include "ui/aura/window.h" |
8 #include "ui/base/ime/input_method.h" | |
8 #include "ui/compositor/layer.h" | 9 #include "ui/compositor/layer.h" |
10 #include "ui/events/event_rewriter.h" | |
11 | |
12 namespace { | |
13 | |
14 // Counts number of events observed. | |
15 class CounterEventRewriter : public ui::EventRewriter { | |
16 public: | |
17 CounterEventRewriter() : events_seen_(0) {} | |
18 ~CounterEventRewriter() override {} | |
19 | |
20 int events_seen() const { return events_seen_; } | |
21 | |
22 private: | |
23 // ui::EventRewriter: | |
24 ui::EventRewriteStatus RewriteEvent( | |
25 const ui::Event& event, | |
26 std::unique_ptr<ui::Event>* new_event) override { | |
27 events_seen_++; | |
28 return ui::EVENT_REWRITE_CONTINUE; | |
29 } | |
30 | |
31 ui::EventRewriteStatus NextDispatchEvent( | |
32 const ui::Event& last_event, | |
33 std::unique_ptr<ui::Event>* new_event) override { | |
34 return ui::EVENT_REWRITE_CONTINUE; | |
35 } | |
36 | |
37 int events_seen_; | |
38 | |
39 DISALLOW_COPY_AND_ASSIGN(CounterEventRewriter); | |
40 }; | |
41 | |
42 } // namespace | |
9 | 43 |
10 namespace aura { | 44 namespace aura { |
11 | 45 |
12 using WindowTreeHostTest = test::AuraTestBase; | 46 using WindowTreeHostTest = test::AuraTestBase; |
13 | 47 |
14 TEST_F(WindowTreeHostTest, DPIWindowSize) { | 48 TEST_F(WindowTreeHostTest, DPIWindowSize) { |
15 gfx::Rect starting_bounds(0, 0, 800, 600); | 49 gfx::Rect starting_bounds(0, 0, 800, 600); |
16 EXPECT_EQ(starting_bounds.size(), host()->compositor()->size()); | 50 EXPECT_EQ(starting_bounds.size(), host()->compositor()->size()); |
17 EXPECT_EQ(starting_bounds, host()->GetBoundsInPixels()); | 51 EXPECT_EQ(starting_bounds, host()->GetBoundsInPixels()); |
18 EXPECT_EQ(starting_bounds, root_window()->bounds()); | 52 EXPECT_EQ(starting_bounds, root_window()->bounds()); |
(...skipping 13 matching lines...) Expand all Loading... | |
32 host()->SetOutputSurfacePaddingInPixels(padding); | 66 host()->SetOutputSurfacePaddingInPixels(padding); |
33 gfx::Rect padded_rect = starting_bounds; | 67 gfx::Rect padded_rect = starting_bounds; |
34 padded_rect.Inset(-padding); | 68 padded_rect.Inset(-padding); |
35 EXPECT_EQ(padded_rect.size(), host()->compositor()->size()); | 69 EXPECT_EQ(padded_rect.size(), host()->compositor()->size()); |
36 EXPECT_EQ(starting_bounds, host()->GetBoundsInPixels()); | 70 EXPECT_EQ(starting_bounds, host()->GetBoundsInPixels()); |
37 EXPECT_EQ(gfx::Rect(1, 1, 534, 401), root_window()->bounds()); | 71 EXPECT_EQ(gfx::Rect(1, 1, 534, 401), root_window()->bounds()); |
38 EXPECT_EQ(gfx::Vector2dF(0, 0), | 72 EXPECT_EQ(gfx::Vector2dF(0, 0), |
39 host()->compositor()->root_layer()->subpixel_position_offset()); | 73 host()->compositor()->root_layer()->subpixel_position_offset()); |
40 } | 74 } |
41 | 75 |
76 TEST_F(WindowTreeHostTest, NoRewritesPostIME) { | |
77 CounterEventRewriter event_rewriter; | |
78 host()->AddEventRewriter(&event_rewriter); | |
79 | |
80 ui::KeyEvent key_event('A', ui::VKEY_A, 0); | |
81 host()->GetInputMethod()->DispatchKeyEvent(&key_event); | |
82 EXPECT_EQ(0, event_rewriter.events_seen()); | |
sadrul
2017/06/02 20:04:39
Can you do SendEventToSink() on the WTH, and verif
| |
83 | |
84 host()->RemoveEventRewriter(&event_rewriter); | |
85 } | |
86 | |
42 } // namespace aura | 87 } // namespace aura |
OLD | NEW |