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

Side by Side Diff: ios/chrome/browser/voice/text_to_speech_parser_unittest.mm

Issue 2449593002: [ios] Adds support for parsing Text-to-Speech search results. (Closed)
Patch Set: Fix AVFoundation dependency. Created 4 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
OLDNEW
(Empty)
1 // Copyright 2015 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 #import <Foundation/Foundation.h>
6
7 #import "ios/chrome/browser/voice/text_to_speech_parser.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9 #import "third_party/google_toolbox_for_mac/src/Foundation/GTMStringEncoding.h"
10
11 // Expose internal parser function for testing.
12 NSData* ExtractVoiceSearchAudioDataFromPageHTML(NSString* pageHTML);
13
14 namespace {
15 NSString* const kValidVoiceSearchHTML =
16 @"<script>(function(){var _a_tts='dGVzdGF1ZG8zMm9pbw==';var _m_tts= {}}";
17 NSString* const kInvalidVoiceSearchHTML = @"no TTS data";
18 } // namespace
19
20 TEST(TextToSpeechParser, ExtractAudioDataValid) {
21 NSData* result =
22 ExtractVoiceSearchAudioDataFromPageHTML(kValidVoiceSearchHTML);
23
24 EXPECT_TRUE(result != nil);
25
26 GTMStringEncoding* base64 = [GTMStringEncoding rfc4648Base64StringEncoding];
27 NSData* expectedData = [base64 decode:@"dGVzdGF1ZG8zMm9pbw=="];
28 EXPECT_TRUE([expectedData isEqualToData:result]);
29 }
30
31 TEST(TextToSpeechParser, ExtractAudioDataNotFound) {
32 NSData* result =
33 ExtractVoiceSearchAudioDataFromPageHTML(kInvalidVoiceSearchHTML);
34 EXPECT_TRUE(result == nil);
35 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698