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

Side by Side Diff: ash/ime/candidate_view_unittest.cc

Issue 406413004: Cleanups for aura/test/event_generator.h (resolve TODOs) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase at r285842 Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
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"
10 #include "ui/aura/window.h" 9 #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
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 aura::test::EventGenerator( 60 event_generator_.reset(new ui::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
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 aura::test::EventGenerator* event_generator() { 100 ui::test::EventGenerator* event_generator() { return event_generator_.get(); }
101 return event_generator_.get();
102 }
103 101
104 private: 102 private:
105 virtual void ButtonPressed(views::Button* sender, 103 virtual void ButtonPressed(views::Button* sender,
106 const ui::Event& event) OVERRIDE { 104 const ui::Event& event) OVERRIDE {
107 last_pressed_ = sender; 105 last_pressed_ = sender;
108 } 106 }
109 107
110 views::Widget* widget_; 108 views::Widget* widget_;
111 views::View* container_; 109 views::View* container_;
112 scoped_ptr<aura::test::EventGenerator> event_generator_; 110 scoped_ptr<ui::test::EventGenerator> event_generator_;
113 views::View* last_pressed_; 111 views::View* last_pressed_;
114 112
115 DISALLOW_COPY_AND_ASSIGN(CandidateViewTest); 113 DISALLOW_COPY_AND_ASSIGN(CandidateViewTest);
116 }; 114 };
117 115
118 TEST_F(CandidateViewTest, MouseHovers) { 116 TEST_F(CandidateViewTest, MouseHovers) {
119 GetCandidateAt(0)->SetHighlighted(true); 117 GetCandidateAt(0)->SetHighlighted(true);
120 118
121 int highlighted_count = 0; 119 int highlighted_count = 0;
122 EXPECT_EQ(0, GetHighlightedIndex(&highlighted_count)); 120 EXPECT_EQ(0, GetHighlightedIndex(&highlighted_count));
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 GetCandidateAt(1)->GetBoundsInScreen().CenterPoint()); 174 GetCandidateAt(1)->GetBoundsInScreen().CenterPoint());
177 EXPECT_EQ(1, GetHighlightedIndex(&highlighted_count)); 175 EXPECT_EQ(1, GetHighlightedIndex(&highlighted_count));
178 EXPECT_EQ(1, highlighted_count); 176 EXPECT_EQ(1, highlighted_count);
179 177
180 event_generator()->ReleaseLeftButton(); 178 event_generator()->ReleaseLeftButton();
181 EXPECT_EQ(1, GetLastPressedIndexAndReset()); 179 EXPECT_EQ(1, GetLastPressedIndexAndReset());
182 } 180 }
183 181
184 } // namespace ime 182 } // namespace ime
185 } // namespace ash 183 } // namespace ash
OLDNEW
« no previous file with comments | « ash/frame/caption_buttons/frame_size_button_unittest.cc ('k') | ash/magnifier/magnification_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698