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

Side by Side Diff: chrome/browser/speech/tts_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 // Unit tests for the TTS Controller. 5 // Unit tests for the TTS Controller.
6 6
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "chrome/browser/speech/tts_controller.h" 8 #include "chrome/browser/speech/tts_controller.h"
9 #include "chrome/browser/speech/tts_platform.h" 9 #include "chrome/browser/speech/tts_platform.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 11
12 class TtsApiControllerTest : public testing::Test { 12 class TtsApiControllerTest : public testing::Test {
13 }; 13 };
14 14
15 // Platform Tts implementation that does nothing. 15 // Platform Tts implementation that does nothing.
16 class DummyTtsPlatformImpl : public TtsPlatformImpl { 16 class DummyTtsPlatformImpl : public TtsPlatformImpl {
17 public: 17 public:
18 DummyTtsPlatformImpl() {} 18 DummyTtsPlatformImpl() {}
19 virtual ~DummyTtsPlatformImpl() {} 19 virtual ~DummyTtsPlatformImpl() {}
20 virtual bool PlatformImplAvailable() { return true; } 20 virtual bool PlatformImplAvailable() OVERRIDE { return true; }
21 virtual bool Speak( 21 virtual bool Speak(
22 int utterance_id, 22 int utterance_id,
23 const std::string& utterance, 23 const std::string& utterance,
24 const std::string& lang, 24 const std::string& lang,
25 const UtteranceContinuousParameters& params) { 25 const UtteranceContinuousParameters& params) OVERRIDE {
26 return true; 26 return true;
27 } 27 }
28 virtual bool IsSpeaking() { return false; } 28 virtual bool IsSpeaking() OVERRIDE { return false; }
29 virtual bool StopSpeaking() { return true; } 29 virtual bool StopSpeaking() OVERRIDE { return true; }
30 virtual bool SendsEvent(TtsEventType event_type) { return false; } 30 virtual bool SendsEvent(TtsEventType event_type) OVERRIDE { return false; }
31 virtual std::string gender() { return std::string(); } 31 virtual std::string gender() OVERRIDE { return std::string(); }
32 virtual std::string error() { return std::string(); } 32 virtual std::string error() OVERRIDE { return std::string(); }
33 virtual void clear_error() {} 33 virtual void clear_error() OVERRIDE {}
34 virtual void set_error(const std::string& error) {} 34 virtual void set_error(const std::string& error) OVERRIDE {}
35 }; 35 };
36 36
37 // Subclass of TtsController with a public ctor and dtor. 37 // Subclass of TtsController with a public ctor and dtor.
38 class TestableTtsController : public TtsController { 38 class TestableTtsController : public TtsController {
39 public: 39 public:
40 TestableTtsController() {} 40 TestableTtsController() {}
41 virtual ~TestableTtsController() {} 41 virtual ~TestableTtsController() {}
42 }; 42 };
43 43
44 TEST_F(TtsApiControllerTest, TestTtsControllerShutdown) { 44 TEST_F(TtsApiControllerTest, TestTtsControllerShutdown) {
45 DummyTtsPlatformImpl platform_impl; 45 DummyTtsPlatformImpl platform_impl;
46 TestableTtsController* controller = 46 TestableTtsController* controller =
47 new TestableTtsController(); 47 new TestableTtsController();
48 controller->SetPlatformImpl(&platform_impl); 48 controller->SetPlatformImpl(&platform_impl);
49 49
50 Utterance* utterance1 = new Utterance(NULL); 50 Utterance* utterance1 = new Utterance(NULL);
51 utterance1->set_can_enqueue(true); 51 utterance1->set_can_enqueue(true);
52 utterance1->set_src_id(1); 52 utterance1->set_src_id(1);
53 controller->SpeakOrEnqueue(utterance1); 53 controller->SpeakOrEnqueue(utterance1);
54 54
55 Utterance* utterance2 = new Utterance(NULL); 55 Utterance* utterance2 = new Utterance(NULL);
56 utterance2->set_can_enqueue(true); 56 utterance2->set_can_enqueue(true);
57 utterance2->set_src_id(2); 57 utterance2->set_src_id(2);
58 controller->SpeakOrEnqueue(utterance2); 58 controller->SpeakOrEnqueue(utterance2);
59 59
60 // Make sure that deleting the controller when there are pending 60 // Make sure that deleting the controller when there are pending
61 // utterances doesn't cause a crash. 61 // utterances doesn't cause a crash.
62 delete controller; 62 delete controller;
63 } 63 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698