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

Side by Side Diff: chrome/browser/speech/speech_recognition_bubble_controller.h

Issue 10703141: End-to-end browser tests for speech recognition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moved test to /chrome/test Created 8 years, 5 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
« no previous file with comments | « no previous file | chrome/browser/speech/speech_recognition_bubble_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef CHROME_BROWSER_SPEECH_SPEECH_RECOGNITION_BUBBLE_CONTROLLER_H_ 5 #ifndef CHROME_BROWSER_SPEECH_SPEECH_RECOGNITION_BUBBLE_CONTROLLER_H_
6 #define CHROME_BROWSER_SPEECH_SPEECH_RECOGNITION_BUBBLE_CONTROLLER_H_ 6 #define CHROME_BROWSER_SPEECH_SPEECH_RECOGNITION_BUBBLE_CONTROLLER_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "chrome/browser/speech/speech_recognition_bubble.h" 10 #include "chrome/browser/speech/speech_recognition_bubble.h"
(...skipping 16 matching lines...) Expand all
27 int session_id, SpeechRecognitionBubble::Button button) = 0; 27 int session_id, SpeechRecognitionBubble::Button button) = 0;
28 28
29 // Invoked when the user clicks outside the speech recognition info bubble 29 // Invoked when the user clicks outside the speech recognition info bubble
30 // causing it to close and input focus to change. 30 // causing it to close and input focus to change.
31 virtual void InfoBubbleFocusChanged(int session_id) = 0; 31 virtual void InfoBubbleFocusChanged(int session_id) = 0;
32 32
33 protected: 33 protected:
34 virtual ~Delegate() {} 34 virtual ~Delegate() {}
35 }; 35 };
36 36
37 // All methods of this delegate are called on the UI thread.
38 class DelegateForTests {
39 public:
40 virtual void BubbleCreated() = 0;
41 virtual void BubbleSwitchedToRecordingMode() = 0;
42 virtual void BubbleSwitchedToRecognizingMode() = 0;
43 virtual void BubbleMessageDisplayed() = 0;
44 virtual void BubbleClosed() = 0;
45 };
46
47 static void SetDelegateForTests(DelegateForTests* delegate_for_tests);
48 static SpeechRecognitionBubbleController* GetInstanceForTests();
49
37 explicit SpeechRecognitionBubbleController(Delegate* delegate); 50 explicit SpeechRecognitionBubbleController(Delegate* delegate);
38 51
39 // Creates and shows a new speech recognition UI bubble in warmup mode. 52 // Creates and shows a new speech recognition UI bubble in warmup mode.
40 void CreateBubble(int session_id, 53 void CreateBubble(int session_id,
41 int render_process_id, 54 int render_process_id,
42 int render_view_id, 55 int render_view_id,
43 const gfx::Rect& element_rect); 56 const gfx::Rect& element_rect);
44 57
45 // Indicates to the user that audio recording is in progress. 58 // Indicates to the user that audio recording is in progress.
46 void SetBubbleRecordingMode(); 59 void SetBubbleRecordingMode();
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 explicit UIRequest(RequestType type_value); 110 explicit UIRequest(RequestType type_value);
98 ~UIRequest(); 111 ~UIRequest();
99 }; 112 };
100 113
101 virtual ~SpeechRecognitionBubbleController(); 114 virtual ~SpeechRecognitionBubbleController();
102 115
103 void InvokeDelegateButtonClicked(SpeechRecognitionBubble::Button button); 116 void InvokeDelegateButtonClicked(SpeechRecognitionBubble::Button button);
104 void InvokeDelegateFocusChanged(); 117 void InvokeDelegateFocusChanged();
105 void ProcessRequestInUiThread(const UIRequest& request); 118 void ProcessRequestInUiThread(const UIRequest& request);
106 119
120 // Instance getter for simulating button presses during tests.
121 static SpeechRecognitionBubbleController* instance_for_tests_;
122
123 // Delegate for receiving events on the UI thread during tests.
124 static DelegateForTests* delegate_for_tests_;
125
107 // *** The following are accessed only on the IO thread. 126 // *** The following are accessed only on the IO thread.
108 Delegate* delegate_; 127 Delegate* delegate_;
109 128
110 // The session id for currently visible bubble. 129 // The session id for currently visible bubble.
111 int current_bubble_session_id_; 130 int current_bubble_session_id_;
112 131
113 // The render process and view ids for the currently visible bubble. 132 // The render process and view ids for the currently visible bubble.
114 int current_bubble_render_process_id_; 133 int current_bubble_render_process_id_;
115 int current_bubble_render_view_id_; 134 int current_bubble_render_view_id_;
116 135
117 RequestType last_request_issued_; 136 RequestType last_request_issued_;
118 137
119 // *** The following are accessed only on the UI thread. 138 // *** The following are accessed only on the UI thread.
120 scoped_ptr<SpeechRecognitionBubble> bubble_; 139 scoped_ptr<SpeechRecognitionBubble> bubble_;
121 }; 140 };
122 141
123 // This typedef is to workaround the issue with certain versions of 142 // This typedef is to workaround the issue with certain versions of
124 // Visual Studio where it gets confused between multiple Delegate 143 // Visual Studio where it gets confused between multiple Delegate
125 // classes and gives a C2500 error. (I saw this error on the try bots - 144 // classes and gives a C2500 error. (I saw this error on the try bots -
126 // the workaround was not needed for my machine). 145 // the workaround was not needed for my machine).
127 typedef SpeechRecognitionBubbleController::Delegate 146 typedef SpeechRecognitionBubbleController::Delegate
128 SpeechRecognitionBubbleControllerDelegate; 147 SpeechRecognitionBubbleControllerDelegate;
129 148
149 typedef SpeechRecognitionBubbleController::DelegateForTests
150 SpeechRecognitionBubbleControllerDelegateForTests;
151
130 } // namespace speech 152 } // namespace speech
131 153
132 #endif // CHROME_BROWSER_SPEECH_SPEECH_RECOGNITION_BUBBLE_CONTROLLER_H_ 154 #endif // CHROME_BROWSER_SPEECH_SPEECH_RECOGNITION_BUBBLE_CONTROLLER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/speech/speech_recognition_bubble_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698