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