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

Side by Side Diff: chrome/browser/extensions/extension_tts_apitest.cc

Issue 9581042: Convert uses of int ms to TimeDelta in chrome/browser/extensions. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 9 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 | « no previous file | no next file » | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/command_line.h" 6 #include "base/command_line.h"
7 #include "base/memory/weak_ptr.h" 7 #include "base/memory/weak_ptr.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "chrome/browser/extensions/extension_apitest.h" 9 #include "chrome/browser/extensions/extension_apitest.h"
10 #include "chrome/browser/extensions/extension_tts_api.h" 10 #include "chrome/browser/extensions/extension_tts_api.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 void SendEndEvent(int utterance_id, 56 void SendEndEvent(int utterance_id,
57 const std::string& utterance, 57 const std::string& utterance,
58 const std::string& lang, 58 const std::string& lang,
59 const UtteranceContinuousParameters& params) { 59 const UtteranceContinuousParameters& params) {
60 MessageLoop::current()->PostDelayedTask( 60 MessageLoop::current()->PostDelayedTask(
61 FROM_HERE, base::Bind( 61 FROM_HERE, base::Bind(
62 &MockExtensionTtsPlatformImpl::SendEvent, 62 &MockExtensionTtsPlatformImpl::SendEvent,
63 ptr_factory_.GetWeakPtr(), 63 ptr_factory_.GetWeakPtr(),
64 false, utterance_id, TTS_EVENT_END, utterance.size(), 64 false, utterance_id, TTS_EVENT_END, utterance.size(),
65 std::string()), 65 std::string()),
66 0); 66 base::TimeDelta());
67 } 67 }
68 68
69 void SendEndEventWhenQueueNotEmpty( 69 void SendEndEventWhenQueueNotEmpty(
70 int utterance_id, 70 int utterance_id,
71 const std::string& utterance, 71 const std::string& utterance,
72 const std::string& lang, 72 const std::string& lang,
73 const UtteranceContinuousParameters& params) { 73 const UtteranceContinuousParameters& params) {
74 MessageLoop::current()->PostDelayedTask( 74 MessageLoop::current()->PostDelayedTask(
75 FROM_HERE, base::Bind( 75 FROM_HERE, base::Bind(
76 &MockExtensionTtsPlatformImpl::SendEvent, 76 &MockExtensionTtsPlatformImpl::SendEvent,
77 ptr_factory_.GetWeakPtr(), 77 ptr_factory_.GetWeakPtr(),
78 true, utterance_id, TTS_EVENT_END, utterance.size(), std::string()), 78 true, utterance_id, TTS_EVENT_END, utterance.size(), std::string()),
79 0); 79 base::TimeDelta());
80 } 80 }
81 81
82 void SendWordEvents(int utterance_id, 82 void SendWordEvents(int utterance_id,
83 const std::string& utterance, 83 const std::string& utterance,
84 const std::string& lang, 84 const std::string& lang,
85 const UtteranceContinuousParameters& params) { 85 const UtteranceContinuousParameters& params) {
86 for (int i = 0; i < static_cast<int>(utterance.size()); i++) { 86 for (int i = 0; i < static_cast<int>(utterance.size()); i++) {
87 if (i == 0 || utterance[i - 1] == ' ') { 87 if (i == 0 || utterance[i - 1] == ' ') {
88 MessageLoop::current()->PostDelayedTask( 88 MessageLoop::current()->PostDelayedTask(
89 FROM_HERE, base::Bind( 89 FROM_HERE, base::Bind(
90 &MockExtensionTtsPlatformImpl::SendEvent, 90 &MockExtensionTtsPlatformImpl::SendEvent,
91 ptr_factory_.GetWeakPtr(), 91 ptr_factory_.GetWeakPtr(),
92 false, utterance_id, TTS_EVENT_WORD, i, 92 false, utterance_id, TTS_EVENT_WORD, i,
93 std::string()), 93 std::string()),
94 0); 94 base::TimeDelta());
95 } 95 }
96 } 96 }
97 } 97 }
98 98
99 void SendEvent(bool wait_for_non_empty_queue, 99 void SendEvent(bool wait_for_non_empty_queue,
100 int utterance_id, 100 int utterance_id,
101 TtsEventType event_type, 101 TtsEventType event_type,
102 int char_index, 102 int char_index,
103 const std::string& message) { 103 const std::string& message) {
104 ExtensionTtsController* controller = ExtensionTtsController::GetInstance(); 104 ExtensionTtsController* controller = ExtensionTtsController::GetInstance();
105 if (wait_for_non_empty_queue && controller->QueueSize() == 0) { 105 if (wait_for_non_empty_queue && controller->QueueSize() == 0) {
106 MessageLoop::current()->PostDelayedTask( 106 MessageLoop::current()->PostDelayedTask(
107 FROM_HERE, base::Bind( 107 FROM_HERE, base::Bind(
108 &MockExtensionTtsPlatformImpl::SendEvent, 108 &MockExtensionTtsPlatformImpl::SendEvent,
109 ptr_factory_.GetWeakPtr(), 109 ptr_factory_.GetWeakPtr(),
110 true, utterance_id, event_type, char_index, message), 110 true, utterance_id, event_type, char_index, message),
111 100); 111 base::TimeDelta::FromMilliseconds(100));
112 return; 112 return;
113 } 113 }
114 114
115 controller->OnTtsEvent(utterance_id, event_type, char_index, message); 115 controller->OnTtsEvent(utterance_id, event_type, char_index, message);
116 } 116 }
117 117
118 private: 118 private:
119 base::WeakPtrFactory<MockExtensionTtsPlatformImpl> ptr_factory_; 119 base::WeakPtrFactory<MockExtensionTtsPlatformImpl> ptr_factory_;
120 }; 120 };
121 121
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 290
291 ASSERT_TRUE(RunExtensionTest("tts_engine/engine_error")) << message_; 291 ASSERT_TRUE(RunExtensionTest("tts_engine/engine_error")) << message_;
292 } 292 }
293 293
294 IN_PROC_BROWSER_TEST_F(TtsApiTest, EngineWordCallbacks) { 294 IN_PROC_BROWSER_TEST_F(TtsApiTest, EngineWordCallbacks) {
295 EXPECT_CALL(mock_platform_impl_, StopSpeaking()) 295 EXPECT_CALL(mock_platform_impl_, StopSpeaking())
296 .WillRepeatedly(Return(true)); 296 .WillRepeatedly(Return(true));
297 297
298 ASSERT_TRUE(RunExtensionTest("tts_engine/engine_word_callbacks")) << message_; 298 ASSERT_TRUE(RunExtensionTest("tts_engine/engine_word_callbacks")) << message_;
299 } 299 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698