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

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

Issue 8437080: Fix crash when TTS utterances are queued on shutdown. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 // Unit tests for the TTS API Controller.
6
7 #include "testing/gtest/include/gtest/gtest.h"
8
9 #include "base/values.h"
10 #include "chrome/browser/extensions/extension_tts_api_controller.h"
11 #include "chrome/browser/extensions/extension_tts_api_platform.h"
12
13 class ExtensionTtsApiControllerTest : public testing::Test {
14 };
15
16 // Platform Tts implementation that does nothing.
17 class DummyExtensionTtsPlatformImpl : public ExtensionTtsPlatformImpl {
18 public:
19 DummyExtensionTtsPlatformImpl() {}
20 virtual ~DummyExtensionTtsPlatformImpl() {}
21 virtual bool PlatformImplAvailable() { return true; }
22 virtual bool Speak(
23 int utterance_id,
24 const std::string& utterance,
25 const std::string& lang,
26 const UtteranceContinuousParameters& params) {
27 return true;
28 }
29 virtual bool StopSpeaking() { return true; }
30 virtual bool SendsEvent(TtsEventType event_type) { return false; }
31 virtual std::string gender() { return std::string(); }
32 virtual std::string error() { return std::string(); }
33 virtual void clear_error() {}
34 virtual void set_error(const std::string& error) {}
35 };
36
37 // Subclass of ExtensionTtsController with a public ctor and dtor.
38 class TestableExtensionTtsController : public ExtensionTtsController {
39 public:
40 TestableExtensionTtsController() {}
41 virtual ~TestableExtensionTtsController() {}
42 };
43
44 TEST_F(ExtensionTtsApiControllerTest, TestTtsControllerShutdown) {
45 DummyExtensionTtsPlatformImpl platform_impl;
46 TestableExtensionTtsController* controller =
47 new TestableExtensionTtsController();
48 controller->SetPlatformImpl(&platform_impl);
49
50 Utterance* utterance1 = new Utterance(NULL);
51 utterance1->set_can_enqueue(true);
52 utterance1->set_src_id(1);
53 controller->SpeakOrEnqueue(utterance1);
54
55 Utterance* utterance2 = new Utterance(NULL);
56 utterance2->set_can_enqueue(true);
57 utterance2->set_src_id(2);
58 controller->SpeakOrEnqueue(utterance2);
59
60 // Make sure that deleting the controller when there are pending
61 // utterances doesn't cause a crash.
62 delete controller;
63 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_tts_api_controller.cc ('k') | chrome/browser/extensions/extension_tts_engine_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698