Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: chrome/browser/speech/speech_recognition_bubble_controller_unittest.cc

Issue 12212048: Linux/ChromeOS Chromium style checker cleanup, chrome/browser edition. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/browser_tabstrip.h"
10 #include "chrome/browser/ui/tabs/tab_strip_model.h" 10 #include "chrome/browser/ui/tabs/tab_strip_model.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 } 56 }
57 } 57 }
58 58
59 static void set_type(BubbleType type) { 59 static void set_type(BubbleType type) {
60 type_ = type; 60 type_ = type;
61 } 61 }
62 static BubbleType type() { 62 static BubbleType type() {
63 return type_; 63 return type_;
64 } 64 }
65 65
66 virtual void Show() {} 66 virtual void Show() OVERRIDE {}
67 virtual void Hide() {} 67 virtual void Hide() OVERRIDE {}
68 virtual void UpdateLayout() {} 68 virtual void UpdateLayout() OVERRIDE {}
69 virtual void UpdateImage() {} 69 virtual void UpdateImage() OVERRIDE {}
70 70
71 private: 71 private:
72 static BubbleType type_; 72 static BubbleType type_;
73 }; 73 };
74 74
75 // The test fixture. 75 // The test fixture.
76 class SpeechRecognitionBubbleControllerTest 76 class SpeechRecognitionBubbleControllerTest
77 : public SpeechRecognitionBubbleControllerDelegate, 77 : public SpeechRecognitionBubbleControllerDelegate,
78 public BrowserWithTestWindowTest { 78 public BrowserWithTestWindowTest {
79 public: 79 public:
80 SpeechRecognitionBubbleControllerTest() 80 SpeechRecognitionBubbleControllerTest()
81 : BrowserWithTestWindowTest(), 81 : BrowserWithTestWindowTest(),
82 io_thread_(BrowserThread::IO), // constructs a new thread and loop 82 io_thread_(BrowserThread::IO), // constructs a new thread and loop
83 cancel_clicked_(false), 83 cancel_clicked_(false),
84 try_again_clicked_(false), 84 try_again_clicked_(false),
85 focus_changed_(false), 85 focus_changed_(false),
86 controller_(ALLOW_THIS_IN_INITIALIZER_LIST( 86 controller_(ALLOW_THIS_IN_INITIALIZER_LIST(
87 new SpeechRecognitionBubbleController(this))) { 87 new SpeechRecognitionBubbleController(this))) {
88 EXPECT_EQ(NULL, test_fixture_); 88 EXPECT_EQ(NULL, test_fixture_);
89 test_fixture_ = this; 89 test_fixture_ = this;
90 } 90 }
91 91
92 ~SpeechRecognitionBubbleControllerTest() { 92 virtual ~SpeechRecognitionBubbleControllerTest() {
93 test_fixture_ = NULL; 93 test_fixture_ = NULL;
94 } 94 }
95 95
96 // SpeechRecognitionBubbleControllerDelegate methods. 96 // SpeechRecognitionBubbleControllerDelegate methods.
97 virtual void InfoBubbleButtonClicked(int session_id, 97 virtual void InfoBubbleButtonClicked(
98 SpeechRecognitionBubble::Button button) { 98 int session_id,
99 SpeechRecognitionBubble::Button button) OVERRIDE {
99 VLOG(1) << "Received InfoBubbleButtonClicked for button " << button; 100 VLOG(1) << "Received InfoBubbleButtonClicked for button " << button;
100 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO)); 101 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO));
101 if (button == SpeechRecognitionBubble::BUTTON_CANCEL) { 102 if (button == SpeechRecognitionBubble::BUTTON_CANCEL) {
102 cancel_clicked_ = true; 103 cancel_clicked_ = true;
103 } else if (button == SpeechRecognitionBubble::BUTTON_TRY_AGAIN) { 104 } else if (button == SpeechRecognitionBubble::BUTTON_TRY_AGAIN) {
104 try_again_clicked_ = true; 105 try_again_clicked_ = true;
105 } 106 }
106 message_loop()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); 107 message_loop()->PostTask(FROM_HERE, MessageLoop::QuitClosure());
107 } 108 }
108 109
109 virtual void InfoBubbleFocusChanged(int session_id) { 110 virtual void InfoBubbleFocusChanged(int session_id) OVERRIDE {
110 VLOG(1) << "Received InfoBubbleFocusChanged"; 111 VLOG(1) << "Received InfoBubbleFocusChanged";
111 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO)); 112 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO));
112 focus_changed_ = true; 113 focus_changed_ = true;
113 message_loop()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); 114 message_loop()->PostTask(FROM_HERE, MessageLoop::QuitClosure());
114 } 115 }
115 116
116 // testing::Test methods. 117 // testing::Test methods.
117 virtual void SetUp() { 118 virtual void SetUp() {
118 BrowserWithTestWindowTest::SetUp(); 119 BrowserWithTestWindowTest::SetUp();
119 SpeechRecognitionBubble::set_factory( 120 SpeechRecognitionBubble::set_factory(
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 214
214 controller_->CreateBubble(kBubbleSessionId, 1, 1, gfx::Rect(1, 1)); 215 controller_->CreateBubble(kBubbleSessionId, 1, 1, gfx::Rect(1, 1));
215 MessageLoop::current()->Run(); 216 MessageLoop::current()->Run();
216 EXPECT_FALSE(cancel_clicked_); 217 EXPECT_FALSE(cancel_clicked_);
217 EXPECT_TRUE(try_again_clicked_); 218 EXPECT_TRUE(try_again_clicked_);
218 EXPECT_FALSE(focus_changed_); 219 EXPECT_FALSE(focus_changed_);
219 controller_->CloseBubble(); 220 controller_->CloseBubble();
220 } 221 }
221 222
222 } // namespace speech 223 } // namespace speech
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698