Check USB device path access when prompting users to select a device.
[chromium-blink-merge.git] / chrome / browser / speech / tts_controller_unittest.cc
blob9aa8450f71909e40c77459f22cabd3355baacc2c
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
3 // found in the LICENSE file.
5 // Unit tests for the TTS Controller.
7 #include "base/values.h"
8 #include "chrome/browser/speech/tts_controller_impl.h"
9 #include "chrome/browser/speech/tts_platform.h"
10 #include "testing/gtest/include/gtest/gtest.h"
12 class TtsApiControllerTest : public testing::Test {
15 // Platform Tts implementation that does nothing.
16 class DummyTtsPlatformImpl : public TtsPlatformImpl {
17 public:
18 DummyTtsPlatformImpl() {}
19 ~DummyTtsPlatformImpl() override {}
20 bool PlatformImplAvailable() override { return true; }
21 bool Speak(int utterance_id,
22 const std::string& utterance,
23 const std::string& lang,
24 const VoiceData& voice,
25 const UtteranceContinuousParameters& params) override {
26 return true;
28 bool IsSpeaking() override { return false; }
29 bool StopSpeaking() override { return true; }
30 void Pause() override {}
31 void Resume() override {}
32 void GetVoices(std::vector<VoiceData>* out_voices) override {}
33 std::string error() override { return std::string(); }
34 void clear_error() override {}
35 void set_error(const std::string& error) override {}
38 // Subclass of TtsController with a public ctor and dtor.
39 class TestableTtsController : public TtsControllerImpl {
40 public:
41 TestableTtsController() {}
42 ~TestableTtsController() override {}
45 TEST_F(TtsApiControllerTest, TestTtsControllerShutdown) {
46 DummyTtsPlatformImpl platform_impl;
47 TestableTtsController* controller =
48 new TestableTtsController();
49 controller->SetPlatformImpl(&platform_impl);
51 Utterance* utterance1 = new Utterance(NULL);
52 utterance1->set_can_enqueue(true);
53 utterance1->set_src_id(1);
54 controller->SpeakOrEnqueue(utterance1);
56 Utterance* utterance2 = new Utterance(NULL);
57 utterance2->set_can_enqueue(true);
58 utterance2->set_src_id(2);
59 controller->SpeakOrEnqueue(utterance2);
61 // Make sure that deleting the controller when there are pending
62 // utterances doesn't cause a crash.
63 delete controller;