[email protected] | 3b63f8f4 | 2011-03-28 01:54:15 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
[email protected] | bd141d8 | 2010-09-21 21:51:43 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | 3b63f8f4 | 2011-03-28 01:54:15 | [diff] [blame] | 5 | #include "base/memory/scoped_ptr.h" |
[email protected] | bd141d8 | 2010-09-21 21:51:43 | [diff] [blame] | 6 | #include "chrome/browser/speech/speech_input_bubble.h" |
[email protected] | f46be6e | 2010-11-16 03:52:32 | [diff] [blame] | 7 | #include "chrome/browser/ui/browser.h" |
[email protected] | a81343d23 | 2011-12-27 07:39:20 | [diff] [blame] | 8 | #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
[email protected] | af44e7fb | 2011-07-29 18:32:32 | [diff] [blame] | 9 | #include "chrome/test/base/in_process_browser_test.h" |
[email protected] | bd141d8 | 2010-09-21 21:51:43 | [diff] [blame] | 10 | #include "testing/gtest/include/gtest/gtest.h" |
[email protected] | 08397d5 | 2011-02-05 01:53:38 | [diff] [blame] | 11 | #include "ui/gfx/rect.h" |
[email protected] | bd141d8 | 2010-09-21 21:51:43 | [diff] [blame] | 12 | |
| 13 | class SpeechInputBubbleTest : public SpeechInputBubbleDelegate, |
| 14 | public InProcessBrowserTest { |
| 15 | public: |
| 16 | // SpeechInputBubble::Delegate methods. |
| 17 | virtual void InfoBubbleButtonClicked(SpeechInputBubble::Button button) {} |
| 18 | virtual void InfoBubbleFocusChanged() {} |
| 19 | |
| 20 | protected: |
| 21 | }; |
| 22 | |
| 23 | IN_PROC_BROWSER_TEST_F(SpeechInputBubbleTest, CreateAndDestroy) { |
| 24 | gfx::Rect element_rect(100, 100, 100, 100); |
| 25 | scoped_ptr<SpeechInputBubble> bubble(SpeechInputBubble::Create( |
[email protected] | 4ca1530 | 2012-01-03 05:53:20 | [diff] [blame] | 26 | browser()->GetSelectedWebContents(), this, element_rect)); |
[email protected] | bd141d8 | 2010-09-21 21:51:43 | [diff] [blame] | 27 | EXPECT_TRUE(bubble.get()); |
| 28 | } |
| 29 | |
| 30 | IN_PROC_BROWSER_TEST_F(SpeechInputBubbleTest, ShowAndDestroy) { |
| 31 | gfx::Rect element_rect(100, 100, 100, 100); |
| 32 | scoped_ptr<SpeechInputBubble> bubble(SpeechInputBubble::Create( |
[email protected] | 4ca1530 | 2012-01-03 05:53:20 | [diff] [blame] | 33 | browser()->GetSelectedWebContents(), this, element_rect)); |
[email protected] | bd141d8 | 2010-09-21 21:51:43 | [diff] [blame] | 34 | EXPECT_TRUE(bubble.get()); |
| 35 | bubble->Show(); |
| 36 | } |
| 37 | |
| 38 | IN_PROC_BROWSER_TEST_F(SpeechInputBubbleTest, ShowAndHide) { |
| 39 | gfx::Rect element_rect(100, 100, 100, 100); |
| 40 | scoped_ptr<SpeechInputBubble> bubble(SpeechInputBubble::Create( |
[email protected] | 4ca1530 | 2012-01-03 05:53:20 | [diff] [blame] | 41 | browser()->GetSelectedWebContents(), this, element_rect)); |
[email protected] | bd141d8 | 2010-09-21 21:51:43 | [diff] [blame] | 42 | EXPECT_TRUE(bubble.get()); |
| 43 | bubble->Show(); |
| 44 | bubble->Hide(); |
| 45 | } |
| 46 | |
| 47 | IN_PROC_BROWSER_TEST_F(SpeechInputBubbleTest, ShowAndHideTwice) { |
| 48 | gfx::Rect element_rect(100, 100, 100, 100); |
| 49 | scoped_ptr<SpeechInputBubble> bubble(SpeechInputBubble::Create( |
[email protected] | 4ca1530 | 2012-01-03 05:53:20 | [diff] [blame] | 50 | browser()->GetSelectedWebContents(), this, element_rect)); |
[email protected] | bd141d8 | 2010-09-21 21:51:43 | [diff] [blame] | 51 | EXPECT_TRUE(bubble.get()); |
| 52 | bubble->Show(); |
| 53 | bubble->Hide(); |
| 54 | bubble->Show(); |
| 55 | bubble->Hide(); |
| 56 | } |