OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/ime/candidate_view.h" | 5 #include "ash/ime/candidate_view.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "ui/aura/test/event_generator.h" |
9 #include "ui/aura/window.h" | 10 #include "ui/aura/window.h" |
10 #include "ui/events/test/event_generator.h" | |
11 #include "ui/views/controls/button/button.h" | 11 #include "ui/views/controls/button/button.h" |
12 #include "ui/views/layout/box_layout.h" | 12 #include "ui/views/layout/box_layout.h" |
13 #include "ui/views/layout/fill_layout.h" | 13 #include "ui/views/layout/fill_layout.h" |
14 #include "ui/views/test/views_test_base.h" | 14 #include "ui/views/test/views_test_base.h" |
15 #include "ui/views/widget/widget_delegate.h" | 15 #include "ui/views/widget/widget_delegate.h" |
16 | 16 |
17 namespace ash { | 17 namespace ash { |
18 namespace ime { | 18 namespace ime { |
19 namespace { | 19 namespace { |
20 | 20 |
(...skipping 29 matching lines...) Expand all Loading... |
50 entry.value = base::UTF8ToUTF16(kDummyCandidates[i]); | 50 entry.value = base::UTF8ToUTF16(kDummyCandidates[i]); |
51 candidate->SetEntry(entry); | 51 candidate->SetEntry(entry); |
52 container_->AddChildView(candidate); | 52 container_->AddChildView(candidate); |
53 } | 53 } |
54 | 54 |
55 widget_ = new views::Widget(); | 55 widget_ = new views::Widget(); |
56 widget_->Init(init_params); | 56 widget_->Init(init_params); |
57 widget_->Show(); | 57 widget_->Show(); |
58 | 58 |
59 aura::Window* native_window = widget_->GetNativeWindow(); | 59 aura::Window* native_window = widget_->GetNativeWindow(); |
60 event_generator_.reset(new ui::test::EventGenerator( | 60 event_generator_.reset(new aura::test::EventGenerator( |
61 native_window->GetRootWindow(), native_window)); | 61 native_window->GetRootWindow(), native_window)); |
62 } | 62 } |
63 | 63 |
64 virtual void TearDown() OVERRIDE { | 64 virtual void TearDown() OVERRIDE { |
65 widget_->Close(); | 65 widget_->Close(); |
66 | 66 |
67 views::ViewsTestBase::TearDown(); | 67 views::ViewsTestBase::TearDown(); |
68 } | 68 } |
69 | 69 |
70 protected: | 70 protected: |
(...skipping 19 matching lines...) Expand all Loading... |
90 last_pressed_ = NULL; | 90 last_pressed_ = NULL; |
91 return i; | 91 return i; |
92 } | 92 } |
93 } | 93 } |
94 | 94 |
95 DCHECK(last_pressed_ == NULL); | 95 DCHECK(last_pressed_ == NULL); |
96 last_pressed_ = NULL; | 96 last_pressed_ = NULL; |
97 return -1; | 97 return -1; |
98 } | 98 } |
99 | 99 |
100 ui::test::EventGenerator* event_generator() { return event_generator_.get(); } | 100 aura::test::EventGenerator* event_generator() { |
| 101 return event_generator_.get(); |
| 102 } |
101 | 103 |
102 private: | 104 private: |
103 virtual void ButtonPressed(views::Button* sender, | 105 virtual void ButtonPressed(views::Button* sender, |
104 const ui::Event& event) OVERRIDE { | 106 const ui::Event& event) OVERRIDE { |
105 last_pressed_ = sender; | 107 last_pressed_ = sender; |
106 } | 108 } |
107 | 109 |
108 views::Widget* widget_; | 110 views::Widget* widget_; |
109 views::View* container_; | 111 views::View* container_; |
110 scoped_ptr<ui::test::EventGenerator> event_generator_; | 112 scoped_ptr<aura::test::EventGenerator> event_generator_; |
111 views::View* last_pressed_; | 113 views::View* last_pressed_; |
112 | 114 |
113 DISALLOW_COPY_AND_ASSIGN(CandidateViewTest); | 115 DISALLOW_COPY_AND_ASSIGN(CandidateViewTest); |
114 }; | 116 }; |
115 | 117 |
116 TEST_F(CandidateViewTest, MouseHovers) { | 118 TEST_F(CandidateViewTest, MouseHovers) { |
117 GetCandidateAt(0)->SetHighlighted(true); | 119 GetCandidateAt(0)->SetHighlighted(true); |
118 | 120 |
119 int highlighted_count = 0; | 121 int highlighted_count = 0; |
120 EXPECT_EQ(0, GetHighlightedIndex(&highlighted_count)); | 122 EXPECT_EQ(0, GetHighlightedIndex(&highlighted_count)); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 GetCandidateAt(1)->GetBoundsInScreen().CenterPoint()); | 176 GetCandidateAt(1)->GetBoundsInScreen().CenterPoint()); |
175 EXPECT_EQ(1, GetHighlightedIndex(&highlighted_count)); | 177 EXPECT_EQ(1, GetHighlightedIndex(&highlighted_count)); |
176 EXPECT_EQ(1, highlighted_count); | 178 EXPECT_EQ(1, highlighted_count); |
177 | 179 |
178 event_generator()->ReleaseLeftButton(); | 180 event_generator()->ReleaseLeftButton(); |
179 EXPECT_EQ(1, GetLastPressedIndexAndReset()); | 181 EXPECT_EQ(1, GetLastPressedIndexAndReset()); |
180 } | 182 } |
181 | 183 |
182 } // namespace ime | 184 } // namespace ime |
183 } // namespace ash | 185 } // namespace ash |
OLD | NEW |