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.
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 "content/public/browser/render_process_host.h"
11 #include "content/public/browser/render_view_host.h"
12 #include "content/public/browser/web_contents.h"
13 #include "testing/gtest/include/gtest/gtest.h"
14 #include "ui/gfx/rect.h"
16 class SpeechRecognitionBubbleTest : public SpeechRecognitionBubbleDelegate,
17 public InProcessBrowserTest {
19 // SpeechRecognitionBubble::Delegate methods.
20 virtual void InfoBubbleButtonClicked(
21 SpeechRecognitionBubble::Button button) OVERRIDE {
23 virtual void InfoBubbleFocusChanged() OVERRIDE {}
28 IN_PROC_BROWSER_TEST_F(SpeechRecognitionBubbleTest, CreateAndDestroy) {
29 gfx::Rect element_rect(100, 100, 100, 100);
30 content::WebContents* web_contents =
31 browser()->tab_strip_model()->GetActiveWebContents();
32 scoped_ptr<SpeechRecognitionBubble> bubble(SpeechRecognitionBubble::Create(
33 web_contents->GetRenderProcessHost()->GetID(),
34 web_contents->GetRenderViewHost()->GetRoutingID(),
36 EXPECT_TRUE(bubble.get());
39 IN_PROC_BROWSER_TEST_F(SpeechRecognitionBubbleTest, ShowAndDestroy) {
40 gfx::Rect element_rect(100, 100, 100, 100);
41 content::WebContents* web_contents =
42 browser()->tab_strip_model()->GetActiveWebContents();
43 scoped_ptr<SpeechRecognitionBubble> bubble(SpeechRecognitionBubble::Create(
44 web_contents->GetRenderProcessHost()->GetID(),
45 web_contents->GetRenderViewHost()->GetRoutingID(),
47 EXPECT_TRUE(bubble.get());
51 IN_PROC_BROWSER_TEST_F(SpeechRecognitionBubbleTest, ShowAndHide) {
52 gfx::Rect element_rect(100, 100, 100, 100);
53 content::WebContents* web_contents =
54 browser()->tab_strip_model()->GetActiveWebContents();
55 scoped_ptr<SpeechRecognitionBubble> bubble(SpeechRecognitionBubble::Create(
56 web_contents->GetRenderProcessHost()->GetID(),
57 web_contents->GetRenderViewHost()->GetRoutingID(),
59 EXPECT_TRUE(bubble.get());
64 IN_PROC_BROWSER_TEST_F(SpeechRecognitionBubbleTest, ShowAndHideTwice) {
65 gfx::Rect element_rect(100, 100, 100, 100);
66 content::WebContents* web_contents =
67 browser()->tab_strip_model()->GetActiveWebContents();
68 scoped_ptr<SpeechRecognitionBubble> bubble(SpeechRecognitionBubble::Create(
69 web_contents->GetRenderProcessHost()->GetID(),
70 web_contents->GetRenderViewHost()->GetRoutingID(),
72 EXPECT_TRUE(bubble.get());