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

Unified 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, 7 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 side-by-side diff with in-line comments
Download patch
Index: ui/app_list/views/speech_view_unittest.cc
diff --git a/ui/app_list/views/speech_view_unittest.cc b/ui/app_list/views/speech_view_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..fed4385f1c08873adf949ed0687e9369604c3d02
--- /dev/null
+++ b/ui/app_list/views/speech_view_unittest.cc
@@ -0,0 +1,63 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/app_list/views/speech_view.h"
+
+#include "ui/app_list/test/app_list_test_view_delegate.h"
+#include "ui/views/test/widget_test.h"
+#include "ui/views/controls/button/image_button.h"
+
+namespace app_list {
+namespace test {
+
+class SpeechViewTest : public views::test::WidgetTest,
+ public AppListTestViewDelegate {
+ public:
+ SpeechViewTest() {}
+ virtual ~SpeechViewTest() {}
+
+ // Overridden from testing::Test:
+ virtual void SetUp() OVERRIDE {
+ views::test::WidgetTest::SetUp();
+ 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.
+ view_ = new SpeechView(&view_delegate_);
+ widget_->GetContentsView()->AddChildView(view_);
+ 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.
+ }
+
+ virtual void TearDown() OVERRIDE {
+ widget_->CloseNow();
+ views::test::WidgetTest::TearDown();
+ }
+
+ protected:
+ SpeechView* view() { return view_; }
+ views::Widget* widget() { return widget_; }
+
+ int GetToggleSpeechRecognitionCountAndReset() {
+ return view_delegate_.GetToggleSpeechRecognitionCountAndReset();
+ }
+
+ private:
+ AppListTestViewDelegate view_delegate_;
+ views::Widget* widget_;
+ SpeechView* view_;
+
+ DISALLOW_COPY_AND_ASSIGN(SpeechViewTest);
+};
+
+TEST_F(SpeechViewTest, Basic) {
+ EXPECT_EQ(0, GetToggleSpeechRecognitionCountAndReset());
+ gfx::Rect screen_bounds(view()->mic_button()->GetBoundsInScreen());
+
+ 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.
+ ui::MouseEvent release(ui::ET_MOUSE_RELEASED, screen_bounds.CenterPoint(), screen_bounds.CenterPoint(), 0, 0);
+ widget()->OnMouseEvent(&press);
+ widget()->OnMouseEvent(&release);
+
+ EXPECT_EQ(1, GetToggleSpeechRecognitionCountAndReset());
+}
+
+} // namespace test
+} // namespace app_list

Powered by Google App Engine
This is Rietveld 408576698