| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/utf_string_conversions.h" | 5 #include "base/utf_string_conversions.h" |
| 6 #include "chrome/browser/browser_thread.h" | 6 #include "chrome/browser/browser_thread.h" |
| 7 #include "chrome/browser/speech/speech_input_bubble_controller.h" | 7 #include "chrome/browser/speech/speech_input_bubble_controller.h" |
| 8 #include "gfx/rect.h" | 8 #include "gfx/rect.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| 11 class SkBitmap; | 11 class SkBitmap; |
| 12 | 12 |
| 13 namespace speech_input { | 13 namespace speech_input { |
| 14 | 14 |
| 15 // A mock bubble class which fakes a focus change or recognition cancel by the | 15 // A mock bubble class which fakes a focus change or recognition cancel by the |
| 16 // user and closing of the info bubble. | 16 // user and closing of the info bubble. |
| 17 class MockSpeechInputBubble : public SpeechInputBubbleBase { | 17 class MockSpeechInputBubble : public SpeechInputBubbleBase { |
| 18 public: | 18 public: |
| 19 enum BubbleType { | 19 enum BubbleType { |
| 20 BUBBLE_TEST_FOCUS_CHANGED, | 20 BUBBLE_TEST_FOCUS_CHANGED, |
| 21 BUBBLE_TEST_CLICK_CANCEL, | 21 BUBBLE_TEST_CLICK_CANCEL, |
| 22 BUBBLE_TEST_CLICK_TRY_AGAIN, | 22 BUBBLE_TEST_CLICK_TRY_AGAIN, |
| 23 }; | 23 }; |
| 24 | 24 |
| 25 MockSpeechInputBubble(TabContents*, Delegate* delegate, const gfx::Rect&) { | 25 MockSpeechInputBubble(TabContents* tab_contents, |
| 26 Delegate* delegate, |
| 27 const gfx::Rect&) |
| 28 : SpeechInputBubbleBase(tab_contents) { |
| 26 VLOG(1) << "MockSpeechInputBubble created"; | 29 VLOG(1) << "MockSpeechInputBubble created"; |
| 27 MessageLoop::current()->PostTask( | 30 MessageLoop::current()->PostTask( |
| 28 FROM_HERE, NewRunnableFunction(&InvokeDelegate, delegate)); | 31 FROM_HERE, NewRunnableFunction(&InvokeDelegate, delegate)); |
| 29 } | 32 } |
| 30 | 33 |
| 31 static void InvokeDelegate(Delegate* delegate) { | 34 static void InvokeDelegate(Delegate* delegate) { |
| 32 VLOG(1) << "MockSpeechInputBubble invoking delegate for type " << type_; | 35 VLOG(1) << "MockSpeechInputBubble invoking delegate for type " << type_; |
| 33 switch (type_) { | 36 switch (type_) { |
| 34 case BUBBLE_TEST_FOCUS_CHANGED: | 37 case BUBBLE_TEST_FOCUS_CHANGED: |
| 35 delegate->InfoBubbleFocusChanged(); | 38 delegate->InfoBubbleFocusChanged(); |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 | 197 |
| 195 controller_->CreateBubble(kBubbleCallerId, 1, 1, gfx::Rect(1, 1)); | 198 controller_->CreateBubble(kBubbleCallerId, 1, 1, gfx::Rect(1, 1)); |
| 196 MessageLoop::current()->Run(); | 199 MessageLoop::current()->Run(); |
| 197 EXPECT_FALSE(cancel_clicked_); | 200 EXPECT_FALSE(cancel_clicked_); |
| 198 EXPECT_TRUE(try_again_clicked_); | 201 EXPECT_TRUE(try_again_clicked_); |
| 199 EXPECT_FALSE(focus_changed_); | 202 EXPECT_FALSE(focus_changed_); |
| 200 controller_->CloseBubble(kBubbleCallerId); | 203 controller_->CloseBubble(kBubbleCallerId); |
| 201 } | 204 } |
| 202 | 205 |
| 203 } // namespace speech_input | 206 } // namespace speech_input |
| OLD | NEW |