1 // Copyright (c) 2012 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 "base/memory/scoped_ptr.h" 6 #include "chrome/browser/speech/speech_recognition_bubble.h" 7 #include "chrome/browser/ui/browser.h" 8 #include "chrome/browser/ui/tabs/tab_strip_model.h" 9 #include "chrome/test/base/in_process_browser_test.h" 10 #include "testing/gtest/include/gtest/gtest.h" 11 #include "ui/gfx/rect.h" 12 13 class SpeechRecognitionBubbleTest : public SpeechRecognitionBubbleDelegate, 14 public InProcessBrowserTest { 15 public: 16 // SpeechRecognitionBubble::Delegate methods. 17 virtual void InfoBubbleButtonClicked( 18 SpeechRecognitionBubble::Button button) OVERRIDE { 19 } 20 virtual void InfoBubbleFocusChanged() OVERRIDE {} 21 22 protected: 23 }; 24 25 IN_PROC_BROWSER_TEST_F(SpeechRecognitionBubbleTest, CreateAndDestroy) { 26 gfx::Rect element_rect(100, 100, 100, 100); 27 scoped_ptr<SpeechRecognitionBubble> bubble(SpeechRecognitionBubble::Create( 28 browser()->tab_strip_model()->GetActiveWebContents(), 29 this, element_rect)); 30 EXPECT_TRUE(bubble.get()); 31 } 32 33 IN_PROC_BROWSER_TEST_F(SpeechRecognitionBubbleTest, ShowAndDestroy) { 34 gfx::Rect element_rect(100, 100, 100, 100); 35 scoped_ptr<SpeechRecognitionBubble> bubble(SpeechRecognitionBubble::Create( 36 browser()->tab_strip_model()->GetActiveWebContents(), 37 this, element_rect)); 38 EXPECT_TRUE(bubble.get()); 39 bubble->Show(); 40 } 41 42 IN_PROC_BROWSER_TEST_F(SpeechRecognitionBubbleTest, ShowAndHide) { 43 gfx::Rect element_rect(100, 100, 100, 100); 44 scoped_ptr<SpeechRecognitionBubble> bubble(SpeechRecognitionBubble::Create( 45 browser()->tab_strip_model()->GetActiveWebContents(), 46 this, element_rect)); 47 EXPECT_TRUE(bubble.get()); 48 bubble->Show(); 49 bubble->Hide(); 50 } 51 52 IN_PROC_BROWSER_TEST_F(SpeechRecognitionBubbleTest, ShowAndHideTwice) { 53 gfx::Rect element_rect(100, 100, 100, 100); 54 scoped_ptr<SpeechRecognitionBubble> bubble(SpeechRecognitionBubble::Create( 55 browser()->tab_strip_model()->GetActiveWebContents(), 56 this, element_rect)); 57 EXPECT_TRUE(bubble.get()); 58 bubble->Show(); 59 bubble->Hide(); 60 bubble->Show(); 61 bubble->Hide(); 62 } 63