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

Side by Side Diff: content/browser/speech/google_one_shot_remote_engine_unittest.cc

Issue 121033002: Update uses of UTF conversions in content/ to use the base:: namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 12 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 #include "base/message_loop/message_loop.h" 5 #include "base/message_loop/message_loop.h"
6 #include "base/strings/utf_string_conversions.h" 6 #include "base/strings/utf_string_conversions.h"
7 #include "content/browser/speech/audio_buffer.h" 7 #include "content/browser/speech/audio_buffer.h"
8 #include "content/browser/speech/google_one_shot_remote_engine.h" 8 #include "content/browser/speech/google_one_shot_remote_engine.h"
9 #include "content/public/common/speech_recognition_error.h" 9 #include "content/public/common/speech_recognition_error.h"
10 #include "content/public/common/speech_recognition_result.h" 10 #include "content/public/common/speech_recognition_result.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 // Parsed response will be available in result(). 76 // Parsed response will be available in result().
77 } 77 }
78 78
79 TEST_F(GoogleOneShotRemoteEngineTest, BasicTest) { 79 TEST_F(GoogleOneShotRemoteEngineTest, BasicTest) {
80 // Normal success case with one result. 80 // Normal success case with one result.
81 CreateAndTestRequest(true, 81 CreateAndTestRequest(true,
82 "{\"status\":0,\"hypotheses\":" 82 "{\"status\":0,\"hypotheses\":"
83 "[{\"utterance\":\"123456\",\"confidence\":0.9}]}"); 83 "[{\"utterance\":\"123456\",\"confidence\":0.9}]}");
84 EXPECT_EQ(error_, SPEECH_RECOGNITION_ERROR_NONE); 84 EXPECT_EQ(error_, SPEECH_RECOGNITION_ERROR_NONE);
85 EXPECT_EQ(1U, result().hypotheses.size()); 85 EXPECT_EQ(1U, result().hypotheses.size());
86 EXPECT_EQ(ASCIIToUTF16("123456"), result().hypotheses[0].utterance); 86 EXPECT_EQ(base::ASCIIToUTF16("123456"), result().hypotheses[0].utterance);
87 EXPECT_EQ(0.9, result().hypotheses[0].confidence); 87 EXPECT_EQ(0.9, result().hypotheses[0].confidence);
88 88
89 // Normal success case with multiple results. 89 // Normal success case with multiple results.
90 CreateAndTestRequest(true, 90 CreateAndTestRequest(true,
91 "{\"status\":0,\"hypotheses\":[" 91 "{\"status\":0,\"hypotheses\":["
92 "{\"utterance\":\"hello\",\"confidence\":0.9}," 92 "{\"utterance\":\"hello\",\"confidence\":0.9},"
93 "{\"utterance\":\"123456\",\"confidence\":0.5}]}"); 93 "{\"utterance\":\"123456\",\"confidence\":0.5}]}");
94 EXPECT_EQ(error_, SPEECH_RECOGNITION_ERROR_NONE); 94 EXPECT_EQ(error_, SPEECH_RECOGNITION_ERROR_NONE);
95 EXPECT_EQ(2u, result().hypotheses.size()); 95 EXPECT_EQ(2u, result().hypotheses.size());
96 EXPECT_EQ(ASCIIToUTF16("hello"), result().hypotheses[0].utterance); 96 EXPECT_EQ(base::ASCIIToUTF16("hello"), result().hypotheses[0].utterance);
97 EXPECT_EQ(0.9, result().hypotheses[0].confidence); 97 EXPECT_EQ(0.9, result().hypotheses[0].confidence);
98 EXPECT_EQ(ASCIIToUTF16("123456"), result().hypotheses[1].utterance); 98 EXPECT_EQ(base::ASCIIToUTF16("123456"), result().hypotheses[1].utterance);
99 EXPECT_EQ(0.5, result().hypotheses[1].confidence); 99 EXPECT_EQ(0.5, result().hypotheses[1].confidence);
100 100
101 // Zero results. 101 // Zero results.
102 CreateAndTestRequest(true, "{\"status\":0,\"hypotheses\":[]}"); 102 CreateAndTestRequest(true, "{\"status\":0,\"hypotheses\":[]}");
103 EXPECT_EQ(error_, SPEECH_RECOGNITION_ERROR_NONE); 103 EXPECT_EQ(error_, SPEECH_RECOGNITION_ERROR_NONE);
104 EXPECT_EQ(0U, result().hypotheses.size()); 104 EXPECT_EQ(0U, result().hypotheses.size());
105 105
106 // Http failure case. 106 // Http failure case.
107 CreateAndTestRequest(false, std::string()); 107 CreateAndTestRequest(false, std::string());
108 EXPECT_EQ(error_, SPEECH_RECOGNITION_ERROR_NETWORK); 108 EXPECT_EQ(error_, SPEECH_RECOGNITION_ERROR_NETWORK);
(...skipping 10 matching lines...) Expand all
119 EXPECT_EQ(0U, result().hypotheses.size()); 119 EXPECT_EQ(0U, result().hypotheses.size());
120 120
121 // Malformed JSON case. 121 // Malformed JSON case.
122 CreateAndTestRequest(true, "{\"status\":0,\"hypotheses\":" 122 CreateAndTestRequest(true, "{\"status\":0,\"hypotheses\":"
123 "[{\"unknownkey\":\"hello\"}]}"); 123 "[{\"unknownkey\":\"hello\"}]}");
124 EXPECT_EQ(error_, SPEECH_RECOGNITION_ERROR_NETWORK); 124 EXPECT_EQ(error_, SPEECH_RECOGNITION_ERROR_NETWORK);
125 EXPECT_EQ(0U, result().hypotheses.size()); 125 EXPECT_EQ(0U, result().hypotheses.size());
126 } 126 }
127 127
128 } // namespace content 128 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/session_history_browsertest.cc ('k') | content/browser/speech/google_streaming_remote_engine.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698