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

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

Issue 1159623009: content: Remove use of MessageLoopProxy and deprecated MessageLoop APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Test build fix. Created 5 years, 6 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
« no previous file with comments | « content/public/test/browser_test_base.cc ('k') | content/public/test/frame_load_waiter.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) 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/message_loop.h" 8 #include "base/location.h"
9 #include "base/single_thread_task_runner.h"
9 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "base/thread_task_runner_handle.h"
10 #include "content/public/browser/speech_recognition_event_listener.h" 12 #include "content/public/browser/speech_recognition_event_listener.h"
11 #include "content/public/browser/speech_recognition_manager_delegate.h" 13 #include "content/public/browser/speech_recognition_manager_delegate.h"
12 #include "content/public/common/speech_recognition_result.h" 14 #include "content/public/common/speech_recognition_result.h"
13 #include "content/public/test/test_utils.h" 15 #include "content/public/test/test_utils.h"
14 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
15 17
16 namespace { 18 namespace {
17 const char kTestResult[] = "Pictures of the moon"; 19 const char kTestResult[] = "Pictures of the moon";
18 20
19 void RunCallback(const base::Closure recognition_started_closure) { 21 void RunCallback(const base::Closure recognition_started_closure) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 void FakeSpeechRecognitionManager::StartSession(int session_id) { 74 void FakeSpeechRecognitionManager::StartSession(int session_id) {
73 VLOG(1) << "FAKE StartSession invoked."; 75 VLOG(1) << "FAKE StartSession invoked.";
74 EXPECT_EQ(session_id, session_id_); 76 EXPECT_EQ(session_id, session_id_);
75 EXPECT_TRUE(listener_ != NULL); 77 EXPECT_TRUE(listener_ != NULL);
76 78
77 if (delegate_) 79 if (delegate_)
78 delegate_->GetEventListener()->OnRecognitionStart(session_id_); 80 delegate_->GetEventListener()->OnRecognitionStart(session_id_);
79 81
80 if (should_send_fake_response_) { 82 if (should_send_fake_response_) {
81 // Give the fake result in a short while. 83 // Give the fake result in a short while.
82 base::MessageLoop::current()->PostTask( 84 base::ThreadTaskRunnerHandle::Get()->PostTask(
83 FROM_HERE, 85 FROM_HERE,
84 base::Bind( 86 base::Bind(
85 &FakeSpeechRecognitionManager::SetFakeRecognitionResult, 87 &FakeSpeechRecognitionManager::SetFakeRecognitionResult,
86 // This class does not need to be refcounted (typically done by 88 // This class does not need to be refcounted (typically done by
87 // PostTask) since it will outlive the test and gets released only 89 // PostTask) since it will outlive the test and gets released only
88 // when the test shuts down. Disabling refcounting here saves a bit 90 // when the test shuts down. Disabling refcounting here saves a bit
89 // of unnecessary code and the factory method can return a plain 91 // of unnecessary code and the factory method can return a plain
90 // pointer below as required by the real code. 92 // pointer below as required by the real code.
91 base::Unretained(this))); 93 base::Unretained(this)));
92 } 94 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 SpeechRecognitionResults results; 164 SpeechRecognitionResults results;
163 results.push_back(result); 165 results.push_back(result);
164 listener_->OnRecognitionResults(session_id_, results); 166 listener_->OnRecognitionResults(session_id_, results);
165 listener_->OnRecognitionEnd(session_id_); 167 listener_->OnRecognitionEnd(session_id_);
166 session_id_ = 0; 168 session_id_ = 0;
167 listener_ = NULL; 169 listener_ = NULL;
168 VLOG(1) << "Finished setting fake recognition result."; 170 VLOG(1) << "Finished setting fake recognition result.";
169 } 171 }
170 172
171 } // namespace content 173 } // namespace content
OLDNEW
« no previous file with comments | « content/public/test/browser_test_base.cc ('k') | content/public/test/frame_load_waiter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698