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

Side by Side Diff: chrome/browser/speech/tts_controller_unittest.cc

Issue 412783002: Separate out the TtsController interface from it's impl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix unit test and remove comments Created 6 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
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_impl.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() {}
(...skipping 11 matching lines...) Expand all
30 virtual bool StopSpeaking() OVERRIDE { return true; } 30 virtual bool StopSpeaking() OVERRIDE { return true; }
31 virtual void Pause() OVERRIDE {} 31 virtual void Pause() OVERRIDE {}
32 virtual void Resume() OVERRIDE {} 32 virtual void Resume() OVERRIDE {}
33 virtual void GetVoices(std::vector<VoiceData>* out_voices) OVERRIDE {} 33 virtual void GetVoices(std::vector<VoiceData>* out_voices) OVERRIDE {}
34 virtual std::string error() OVERRIDE { return std::string(); } 34 virtual std::string error() OVERRIDE { return std::string(); }
35 virtual void clear_error() OVERRIDE {} 35 virtual void clear_error() OVERRIDE {}
36 virtual void set_error(const std::string& error) OVERRIDE {} 36 virtual void set_error(const std::string& error) OVERRIDE {}
37 }; 37 };
38 38
39 // Subclass of TtsController with a public ctor and dtor. 39 // Subclass of TtsController with a public ctor and dtor.
40 class TestableTtsController : public TtsController { 40 class TestableTtsController : public TtsControllerImpl {
41 public: 41 public:
42 TestableTtsController() {} 42 TestableTtsController() {}
43 virtual ~TestableTtsController() {} 43 virtual ~TestableTtsController() {}
44 }; 44 };
45 45
46 TEST_F(TtsApiControllerTest, TestTtsControllerShutdown) { 46 TEST_F(TtsApiControllerTest, TestTtsControllerShutdown) {
47 DummyTtsPlatformImpl platform_impl; 47 DummyTtsPlatformImpl platform_impl;
48 TestableTtsController* controller = 48 TestableTtsController* controller =
49 new TestableTtsController(); 49 new TestableTtsController();
50 controller->SetPlatformImpl(&platform_impl); 50 controller->SetPlatformImpl(&platform_impl);
51 51
52 Utterance* utterance1 = new Utterance(NULL); 52 Utterance* utterance1 = new Utterance(NULL);
53 utterance1->set_can_enqueue(true); 53 utterance1->set_can_enqueue(true);
54 utterance1->set_src_id(1); 54 utterance1->set_src_id(1);
55 controller->SpeakOrEnqueue(utterance1); 55 controller->SpeakOrEnqueue(utterance1);
56 56
57 Utterance* utterance2 = new Utterance(NULL); 57 Utterance* utterance2 = new Utterance(NULL);
58 utterance2->set_can_enqueue(true); 58 utterance2->set_can_enqueue(true);
59 utterance2->set_src_id(2); 59 utterance2->set_src_id(2);
60 controller->SpeakOrEnqueue(utterance2); 60 controller->SpeakOrEnqueue(utterance2);
61 61
62 // Make sure that deleting the controller when there are pending 62 // Make sure that deleting the controller when there are pending
63 // utterances doesn't cause a crash. 63 // utterances doesn't cause a crash.
64 delete controller; 64 delete controller;
65 } 65 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698