OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
6 #include "chrome/browser/speech/speech_recognition_bubble.h" | 6 #include "chrome/browser/speech/speech_recognition_bubble.h" |
7 #include "chrome/browser/ui/browser.h" | 7 #include "chrome/browser/ui/browser.h" |
8 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 8 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
9 #include "chrome/test/base/in_process_browser_test.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" |
10 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
11 #include "ui/gfx/rect.h" | 14 #include "ui/gfx/rect.h" |
12 | 15 |
13 class SpeechRecognitionBubbleTest : public SpeechRecognitionBubbleDelegate, | 16 class SpeechRecognitionBubbleTest : public SpeechRecognitionBubbleDelegate, |
14 public InProcessBrowserTest { | 17 public InProcessBrowserTest { |
15 public: | 18 public: |
16 // SpeechRecognitionBubble::Delegate methods. | 19 // SpeechRecognitionBubble::Delegate methods. |
17 virtual void InfoBubbleButtonClicked( | 20 virtual void InfoBubbleButtonClicked( |
18 SpeechRecognitionBubble::Button button) OVERRIDE { | 21 SpeechRecognitionBubble::Button button) OVERRIDE { |
19 } | 22 } |
20 virtual void InfoBubbleFocusChanged() OVERRIDE {} | 23 virtual void InfoBubbleFocusChanged() OVERRIDE {} |
21 | 24 |
22 protected: | 25 protected: |
23 }; | 26 }; |
24 | 27 |
25 IN_PROC_BROWSER_TEST_F(SpeechRecognitionBubbleTest, CreateAndDestroy) { | 28 IN_PROC_BROWSER_TEST_F(SpeechRecognitionBubbleTest, CreateAndDestroy) { |
26 gfx::Rect element_rect(100, 100, 100, 100); | 29 gfx::Rect element_rect(100, 100, 100, 100); |
| 30 content::WebContents* web_contents = |
| 31 browser()->tab_strip_model()->GetActiveWebContents(); |
27 scoped_ptr<SpeechRecognitionBubble> bubble(SpeechRecognitionBubble::Create( | 32 scoped_ptr<SpeechRecognitionBubble> bubble(SpeechRecognitionBubble::Create( |
28 browser()->tab_strip_model()->GetActiveWebContents(), | 33 web_contents->GetRenderProcessHost()->GetID(), |
29 this, element_rect)); | 34 web_contents->GetRenderViewHost()->GetRoutingID(), |
| 35 this, element_rect)); |
30 EXPECT_TRUE(bubble.get()); | 36 EXPECT_TRUE(bubble.get()); |
31 } | 37 } |
32 | 38 |
33 IN_PROC_BROWSER_TEST_F(SpeechRecognitionBubbleTest, ShowAndDestroy) { | 39 IN_PROC_BROWSER_TEST_F(SpeechRecognitionBubbleTest, ShowAndDestroy) { |
34 gfx::Rect element_rect(100, 100, 100, 100); | 40 gfx::Rect element_rect(100, 100, 100, 100); |
| 41 content::WebContents* web_contents = |
| 42 browser()->tab_strip_model()->GetActiveWebContents(); |
35 scoped_ptr<SpeechRecognitionBubble> bubble(SpeechRecognitionBubble::Create( | 43 scoped_ptr<SpeechRecognitionBubble> bubble(SpeechRecognitionBubble::Create( |
36 browser()->tab_strip_model()->GetActiveWebContents(), | 44 web_contents->GetRenderProcessHost()->GetID(), |
37 this, element_rect)); | 45 web_contents->GetRenderViewHost()->GetRoutingID(), |
| 46 this, element_rect)); |
38 EXPECT_TRUE(bubble.get()); | 47 EXPECT_TRUE(bubble.get()); |
39 bubble->Show(); | 48 bubble->Show(); |
40 } | 49 } |
41 | 50 |
42 IN_PROC_BROWSER_TEST_F(SpeechRecognitionBubbleTest, ShowAndHide) { | 51 IN_PROC_BROWSER_TEST_F(SpeechRecognitionBubbleTest, ShowAndHide) { |
43 gfx::Rect element_rect(100, 100, 100, 100); | 52 gfx::Rect element_rect(100, 100, 100, 100); |
| 53 content::WebContents* web_contents = |
| 54 browser()->tab_strip_model()->GetActiveWebContents(); |
44 scoped_ptr<SpeechRecognitionBubble> bubble(SpeechRecognitionBubble::Create( | 55 scoped_ptr<SpeechRecognitionBubble> bubble(SpeechRecognitionBubble::Create( |
45 browser()->tab_strip_model()->GetActiveWebContents(), | 56 web_contents->GetRenderProcessHost()->GetID(), |
46 this, element_rect)); | 57 web_contents->GetRenderViewHost()->GetRoutingID(), |
| 58 this, element_rect)); |
47 EXPECT_TRUE(bubble.get()); | 59 EXPECT_TRUE(bubble.get()); |
48 bubble->Show(); | 60 bubble->Show(); |
49 bubble->Hide(); | 61 bubble->Hide(); |
50 } | 62 } |
51 | 63 |
52 IN_PROC_BROWSER_TEST_F(SpeechRecognitionBubbleTest, ShowAndHideTwice) { | 64 IN_PROC_BROWSER_TEST_F(SpeechRecognitionBubbleTest, ShowAndHideTwice) { |
53 gfx::Rect element_rect(100, 100, 100, 100); | 65 gfx::Rect element_rect(100, 100, 100, 100); |
| 66 content::WebContents* web_contents = |
| 67 browser()->tab_strip_model()->GetActiveWebContents(); |
54 scoped_ptr<SpeechRecognitionBubble> bubble(SpeechRecognitionBubble::Create( | 68 scoped_ptr<SpeechRecognitionBubble> bubble(SpeechRecognitionBubble::Create( |
55 browser()->tab_strip_model()->GetActiveWebContents(), | 69 web_contents->GetRenderProcessHost()->GetID(), |
56 this, element_rect)); | 70 web_contents->GetRenderViewHost()->GetRoutingID(), |
| 71 this, element_rect)); |
57 EXPECT_TRUE(bubble.get()); | 72 EXPECT_TRUE(bubble.get()); |
58 bubble->Show(); | 73 bubble->Show(); |
59 bubble->Hide(); | 74 bubble->Hide(); |
60 bubble->Show(); | 75 bubble->Show(); |
61 bubble->Hide(); | 76 bubble->Hide(); |
62 } | 77 } |
OLD | NEW |