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

Side by Side Diff: ui/app_list/views/speech_view_unittest.cc

Issue 302653002: Introduce the MicButtonTargeter class (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: test in progress Created 6 years, 6 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ui/app_list/views/speech_view.h"
6
7 #include "ui/app_list/test/app_list_test_view_delegate.h"
8 #include "ui/views/test/widget_test.h"
9 #include "ui/views/controls/button/image_button.h"
10
11 namespace app_list {
12 namespace test {
13
14 class SpeechViewTest : public views::test::WidgetTest,
15 public AppListTestViewDelegate {
16 public:
17 SpeechViewTest() {}
18 virtual ~SpeechViewTest() {}
19
20 // Overridden from testing::Test:
21 virtual void SetUp() OVERRIDE {
22 views::test::WidgetTest::SetUp();
23 widget_ = CreateTopLevelPlatformWidget();
xiyuan 2014/05/29 20:25:12 By default, test widget is very small. Give it a b
tdanderson 2014/05/29 21:34:23 Done.
24 view_ = new SpeechView(&view_delegate_);
25 widget_->GetContentsView()->AddChildView(view_);
26 view_->Layout();
xiyuan 2014/05/29 20:25:12 No need to call Layout explicitly. Instead, we sho
tdanderson 2014/05/29 21:34:23 Done.
27 }
28
29 virtual void TearDown() OVERRIDE {
30 widget_->CloseNow();
31 views::test::WidgetTest::TearDown();
32 }
33
34 protected:
35 SpeechView* view() { return view_; }
36 views::Widget* widget() { return widget_; }
37
38 int GetToggleSpeechRecognitionCountAndReset() {
39 return view_delegate_.GetToggleSpeechRecognitionCountAndReset();
40 }
41
42 private:
43 AppListTestViewDelegate view_delegate_;
44 views::Widget* widget_;
45 SpeechView* view_;
46
47 DISALLOW_COPY_AND_ASSIGN(SpeechViewTest);
48 };
49
50 TEST_F(SpeechViewTest, Basic) {
51 EXPECT_EQ(0, GetToggleSpeechRecognitionCountAndReset());
52 gfx::Rect screen_bounds(view()->mic_button()->GetBoundsInScreen());
53
54 ui::MouseEvent press(ui::ET_MOUSE_PRESSED, screen_bounds.CenterPoint(), screen _bounds.CenterPoint(), 0, 0);
xiyuan 2014/05/29 20:25:12 The mouse event should have ui::EF_LEFT_MOUSE_BUTT
tdanderson 2014/05/29 21:34:23 Done.
55 ui::MouseEvent release(ui::ET_MOUSE_RELEASED, screen_bounds.CenterPoint(), scr een_bounds.CenterPoint(), 0, 0);
56 widget()->OnMouseEvent(&press);
57 widget()->OnMouseEvent(&release);
58
59 EXPECT_EQ(1, GetToggleSpeechRecognitionCountAndReset());
60 }
61
62 } // namespace test
63 } // namespace app_list
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698