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

Side by Side Diff: content/public/test/fake_speech_recognition_manager.cc

Issue 14335017: content: Use base::MessageLoop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 7 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "content/public/test/fake_speech_recognition_manager.h" 5 #include "content/public/test/fake_speech_recognition_manager.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "content/public/browser/speech_recognition_event_listener.h" 10 #include "content/public/browser/speech_recognition_event_listener.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 return session_id_; 47 return session_id_;
48 } 48 }
49 49
50 void FakeSpeechRecognitionManager::StartSession(int session_id) { 50 void FakeSpeechRecognitionManager::StartSession(int session_id) {
51 VLOG(1) << "FAKE StartSession invoked."; 51 VLOG(1) << "FAKE StartSession invoked.";
52 EXPECT_EQ(session_id, session_id_); 52 EXPECT_EQ(session_id, session_id_);
53 EXPECT_TRUE(listener_ != NULL); 53 EXPECT_TRUE(listener_ != NULL);
54 54
55 if (should_send_fake_response_) { 55 if (should_send_fake_response_) {
56 // Give the fake result in a short while. 56 // Give the fake result in a short while.
57 MessageLoop::current()->PostTask(FROM_HERE, base::Bind( 57 base::MessageLoop::current()->PostTask(
58 &FakeSpeechRecognitionManager::SetFakeRecognitionResult, 58 FROM_HERE,
59 // This class does not need to be refcounted (typically done by 59 base::Bind(
60 // PostTask) since it will outlive the test and gets released only 60 &FakeSpeechRecognitionManager::SetFakeRecognitionResult,
61 // when the test shuts down. Disabling refcounting here saves a bit 61 // This class does not need to be refcounted (typically done by
62 // of unnecessary code and the factory method can return a plain 62 // PostTask) since it will outlive the test and gets released only
63 // pointer below as required by the real code. 63 // when the test shuts down. Disabling refcounting here saves a bit
64 base::Unretained(this))); 64 // of unnecessary code and the factory method can return a plain
65 // pointer below as required by the real code.
66 base::Unretained(this)));
65 } 67 }
66 recognition_started_event_.Signal(); 68 recognition_started_event_.Signal();
67 } 69 }
68 70
69 void FakeSpeechRecognitionManager::AbortSession(int session_id) { 71 void FakeSpeechRecognitionManager::AbortSession(int session_id) {
70 VLOG(1) << "FAKE AbortSession invoked."; 72 VLOG(1) << "FAKE AbortSession invoked.";
71 EXPECT_EQ(session_id_, session_id); 73 EXPECT_EQ(session_id_, session_id);
72 session_id_ = 0; 74 session_id_ = 0;
73 listener_ = NULL; 75 listener_ = NULL;
74 } 76 }
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 SpeechRecognitionResults results; 136 SpeechRecognitionResults results;
135 results.push_back(result); 137 results.push_back(result);
136 listener_->OnRecognitionResults(session_id_, results); 138 listener_->OnRecognitionResults(session_id_, results);
137 listener_->OnRecognitionEnd(session_id_); 139 listener_->OnRecognitionEnd(session_id_);
138 session_id_ = 0; 140 session_id_ = 0;
139 listener_ = NULL; 141 listener_ = NULL;
140 VLOG(1) << "Finished setting fake recognition result."; 142 VLOG(1) << "Finished setting fake recognition result.";
141 } 143 }
142 144
143 } // namespace content 145 } // namespace content
OLDNEW
« no previous file with comments | « content/public/test/download_test_observer.cc ('k') | content/public/test/mock_render_process_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698