Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / speech / speech_recognition_bubble_browsertest.cc
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 "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"
15
16 class SpeechRecognitionBubbleTest : public SpeechRecognitionBubbleDelegate,
17                               public InProcessBrowserTest {
18  public:
19   // SpeechRecognitionBubble::Delegate methods.
20   virtual void InfoBubbleButtonClicked(
21       SpeechRecognitionBubble::Button button) OVERRIDE {
22   }
23   virtual void InfoBubbleFocusChanged() OVERRIDE {}
24
25  protected:
26 };
27
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(),
35        this, element_rect));
36   EXPECT_TRUE(bubble.get());
37 }
38
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(),
46        this, element_rect));
47   EXPECT_TRUE(bubble.get());
48   bubble->Show();
49 }
50
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(),
58        this, element_rect));
59   EXPECT_TRUE(bubble.get());
60   bubble->Show();
61   bubble->Hide();
62 }
63
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(),
71        this, element_rect));
72   EXPECT_TRUE(bubble.get());
73   bubble->Show();
74   bubble->Hide();
75   bubble->Show();
76   bubble->Hide();
77 }