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/bind.h" | 5 #include "base/bind.h" |
6 #include "base/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" |
7 #include "chrome/browser/speech/speech_recognition_bubble_controller.h" | 7 #include "chrome/browser/speech/speech_recognition_bubble_controller.h" |
8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
| 9 #include "chrome/browser/ui/browser_tabstrip.h" |
9 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 10 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
10 #include "chrome/test/base/browser_with_test_window_test.h" | 11 #include "chrome/test/base/browser_with_test_window_test.h" |
11 #include "chrome/test/base/testing_profile.h" | 12 #include "chrome/test/base/testing_profile.h" |
12 #include "content/public/test/test_browser_thread.h" | 13 #include "content/public/test/test_browser_thread.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
14 #include "ui/gfx/rect.h" | 15 #include "ui/gfx/rect.h" |
15 | 16 |
16 using content::BrowserThread; | 17 using content::BrowserThread; |
17 using content::WebContents; | 18 using content::WebContents; |
18 | 19 |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 // active. | 147 // active. |
147 MessageLoop::current()->PostTask(FROM_HERE, | 148 MessageLoop::current()->PostTask(FROM_HERE, |
148 base::Bind(&ActivateBubble)); | 149 base::Bind(&ActivateBubble)); |
149 | 150 |
150 // The |tab_contents| parameter would be NULL since the dummy session id | 151 // The |tab_contents| parameter would be NULL since the dummy session id |
151 // passed to CreateBubble would not have matched any active tab. So get a | 152 // passed to CreateBubble would not have matched any active tab. So get a |
152 // real WebContents pointer from the test fixture and pass that, because | 153 // real WebContents pointer from the test fixture and pass that, because |
153 // the bubble controller registers for tab close notifications which need | 154 // the bubble controller registers for tab close notifications which need |
154 // a valid WebContents. | 155 // a valid WebContents. |
155 TabContents* tab_contents = | 156 TabContents* tab_contents = |
156 test_fixture_->browser()->GetActiveTabContents(); | 157 chrome::GetActiveTabContents(test_fixture_->browser()); |
157 if (tab_contents) | 158 if (tab_contents) |
158 web_contents = tab_contents->web_contents(); | 159 web_contents = tab_contents->web_contents(); |
159 return new MockSpeechRecognitionBubble(web_contents, delegate, | 160 return new MockSpeechRecognitionBubble(web_contents, delegate, |
160 element_rect); | 161 element_rect); |
161 } | 162 } |
162 | 163 |
163 protected: | 164 protected: |
164 // The main thread of the test is marked as the IO thread and we create a new | 165 // The main thread of the test is marked as the IO thread and we create a new |
165 // one for the UI thread. | 166 // one for the UI thread. |
166 content::TestBrowserThread io_thread_; | 167 content::TestBrowserThread io_thread_; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 | 218 |
218 controller_->CreateBubble(kBubbleSessionId, 1, 1, gfx::Rect(1, 1)); | 219 controller_->CreateBubble(kBubbleSessionId, 1, 1, gfx::Rect(1, 1)); |
219 MessageLoop::current()->Run(); | 220 MessageLoop::current()->Run(); |
220 EXPECT_FALSE(cancel_clicked_); | 221 EXPECT_FALSE(cancel_clicked_); |
221 EXPECT_TRUE(try_again_clicked_); | 222 EXPECT_TRUE(try_again_clicked_); |
222 EXPECT_FALSE(focus_changed_); | 223 EXPECT_FALSE(focus_changed_); |
223 controller_->CloseBubble(kBubbleSessionId); | 224 controller_->CloseBubble(kBubbleSessionId); |
224 } | 225 } |
225 | 226 |
226 } // namespace speech | 227 } // namespace speech |
OLD | NEW |