testOobeLocalization implementation
[chromium-blink-merge.git] / ui / aura / window_targeter_unittest.cc
blob09392818cde9ed1e9f45429a0bb6d7daa56fc105
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ui/aura/window_targeter.h"
7 #include "ui/aura/test/aura_test_base.h"
8 #include "ui/aura/test/test_event_handler.h"
9 #include "ui/aura/test/test_window_delegate.h"
10 #include "ui/aura/window.h"
12 namespace aura {
14 class WindowTargeterTest : public test::AuraTestBase {
15 public:
16 WindowTargeterTest() {}
17 virtual ~WindowTargeterTest() {}
19 Window* root_window() { return AuraTestBase::root_window(); }
22 TEST_F(WindowTargeterTest, Basic) {
23 test::TestWindowDelegate delegate;
24 scoped_ptr<Window> window(CreateNormalWindow(1, root_window(), &delegate));
25 Window* one = CreateNormalWindow(2, window.get(), &delegate);
26 Window* two = CreateNormalWindow(3, window.get(), &delegate);
28 window->SetBounds(gfx::Rect(0, 0, 100, 100));
29 one->SetBounds(gfx::Rect(0, 0, 500, 100));
30 two->SetBounds(gfx::Rect(501, 0, 500, 1000));
32 root_window()->Show();
34 test::TestEventHandler handler;
35 one->AddPreTargetHandler(&handler);
37 ui::MouseEvent press(ui::ET_MOUSE_PRESSED,
38 gfx::Point(20, 20),
39 gfx::Point(20, 20),
40 ui::EF_NONE,
41 ui::EF_NONE);
42 root_window()->GetDispatcher()->AsWindowTreeHostDelegate()->
43 OnHostMouseEvent(&press);
44 EXPECT_EQ(1, handler.num_mouse_events());
46 handler.Reset();
47 ui::EventDispatchDetails details =
48 root_window()->GetDispatcher()->OnEventFromSource(&press);
49 EXPECT_FALSE(details.dispatcher_destroyed);
50 EXPECT_EQ(1, handler.num_mouse_events());
52 one->RemovePreTargetHandler(&handler);
55 } // namespace aura