OLD | NEW |
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 #include "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/file_path.h" | 6 #include "base/file_path.h" |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "content/test/content_browser_test_utils.h" | 23 #include "content/test/content_browser_test_utils.h" |
24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | 24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
25 | 25 |
26 | 26 |
27 namespace content { | 27 namespace content { |
28 | 28 |
29 | 29 |
30 class SpeechRecognitionBrowserTest : public ContentBrowserTest { | 30 class SpeechRecognitionBrowserTest : public ContentBrowserTest { |
31 public: | 31 public: |
32 // ContentBrowserTest methods | 32 // ContentBrowserTest methods |
33 virtual void SetUpCommandLine(CommandLine* command_line) { | 33 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
34 EXPECT_TRUE(!command_line->HasSwitch(switches::kDisableSpeechInput)); | 34 EXPECT_TRUE(!command_line->HasSwitch(switches::kDisableSpeechInput)); |
35 } | 35 } |
36 | 36 |
37 protected: | 37 protected: |
38 void LoadAndStartSpeechRecognitionTest(const char* filename) { | 38 void LoadAndStartSpeechRecognitionTest(const char* filename) { |
39 // The test page calculates the speech button's coordinate in the page on | 39 // The test page calculates the speech button's coordinate in the page on |
40 // load & sets that coordinate in the URL fragment. We send mouse down & up | 40 // load & sets that coordinate in the URL fragment. We send mouse down & up |
41 // events at that coordinate to trigger speech recognition. | 41 // events at that coordinate to trigger speech recognition. |
42 GURL test_url = GetTestUrl("speech", filename); | 42 GURL test_url = GetTestUrl("speech", filename); |
43 NavigateToURL(shell(), test_url); | 43 NavigateToURL(shell(), test_url); |
(...skipping 24 matching lines...) Expand all Loading... |
68 void RunSpeechRecognitionTest(const char* filename) { | 68 void RunSpeechRecognitionTest(const char* filename) { |
69 // The fake speech input manager would receive the speech input | 69 // The fake speech input manager would receive the speech input |
70 // request and return the test string as recognition result. The test page | 70 // request and return the test string as recognition result. The test page |
71 // then sets the URL fragment as 'pass' if it received the expected string. | 71 // then sets the URL fragment as 'pass' if it received the expected string. |
72 LoadAndStartSpeechRecognitionTest(filename); | 72 LoadAndStartSpeechRecognitionTest(filename); |
73 | 73 |
74 EXPECT_EQ("pass", shell()->web_contents()->GetURL().ref()); | 74 EXPECT_EQ("pass", shell()->web_contents()->GetURL().ref()); |
75 } | 75 } |
76 | 76 |
77 // ContentBrowserTest methods. | 77 // ContentBrowserTest methods. |
78 virtual void SetUpInProcessBrowserTestFixture() { | 78 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
79 fake_speech_recognition_manager_.set_should_send_fake_response(true); | 79 fake_speech_recognition_manager_.set_should_send_fake_response(true); |
80 speech_recognition_manager_ = &fake_speech_recognition_manager_; | 80 speech_recognition_manager_ = &fake_speech_recognition_manager_; |
81 | 81 |
82 // Inject the fake manager factory so that the test result is returned to | 82 // Inject the fake manager factory so that the test result is returned to |
83 // the web page. | 83 // the web page. |
84 SpeechRecognitionManager::SetManagerForTests(speech_recognition_manager_); | 84 SpeechRecognitionManager::SetManagerForTests(speech_recognition_manager_); |
85 } | 85 } |
86 | 86 |
87 virtual void TearDownInProcessBrowserTestFixture() { | 87 virtual void TearDownInProcessBrowserTestFixture() OVERRIDE { |
88 speech_recognition_manager_ = NULL; | 88 speech_recognition_manager_ = NULL; |
89 } | 89 } |
90 | 90 |
91 FakeSpeechRecognitionManager fake_speech_recognition_manager_; | 91 FakeSpeechRecognitionManager fake_speech_recognition_manager_; |
92 | 92 |
93 // This is used by the static |fakeManager|, and it is a pointer rather than a | 93 // This is used by the static |fakeManager|, and it is a pointer rather than a |
94 // direct instance per the style guide. | 94 // direct instance per the style guide. |
95 static SpeechRecognitionManager* speech_recognition_manager_; | 95 static SpeechRecognitionManager* speech_recognition_manager_; |
96 }; | 96 }; |
97 | 97 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 LoadAndStartSpeechRecognitionTest("basic_recognition.html"); | 129 LoadAndStartSpeechRecognitionTest("basic_recognition.html"); |
130 | 130 |
131 // Make the renderer crash. This should trigger | 131 // Make the renderer crash. This should trigger |
132 // InputTagSpeechDispatcherHost to cancel all pending sessions. | 132 // InputTagSpeechDispatcherHost to cancel all pending sessions. |
133 NavigateToURL(shell(), GURL(chrome::kChromeUICrashURL)); | 133 NavigateToURL(shell(), GURL(chrome::kChromeUICrashURL)); |
134 | 134 |
135 EXPECT_TRUE(fake_speech_recognition_manager_.did_cancel_all()); | 135 EXPECT_TRUE(fake_speech_recognition_manager_.did_cancel_all()); |
136 } | 136 } |
137 | 137 |
138 } // namespace content | 138 } // namespace content |
OLD | NEW |