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

Side by Side Diff: components/search_engines/template_url_fetcher_unittest.cc

Issue 1238683003: Unpunycode search keywords and short names. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Remove UTF-8 from source code, use std::string(). Created 5 years, 5 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
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 <string>
6
5 #include "base/callback_helpers.h" 7 #include "base/callback_helpers.h"
6 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
7 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
8 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
9 #include "base/path_service.h" 11 #include "base/path_service.h"
10 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
11 #include "chrome/browser/search_engines/template_url_service_test_util.h" 13 #include "chrome/browser/search_engines/template_url_service_test_util.h"
12 #include "chrome/test/base/testing_profile.h" 14 #include "chrome/test/base/testing_profile.h"
13 #include "components/search_engines/template_url.h" 15 #include "components/search_engines/template_url.h"
14 #include "components/search_engines/template_url_fetcher.h" 16 #include "components/search_engines/template_url_fetcher.h"
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 StartDownload(keyword, osdd_file_name, 318 StartDownload(keyword, osdd_file_name,
317 TemplateURLFetcher::EXPLICIT_PROVIDER, true); 319 TemplateURLFetcher::EXPLICIT_PROVIDER, true);
318 ASSERT_EQ(0, add_provider_called()); 320 ASSERT_EQ(0, add_provider_called());
319 ASSERT_EQ(1, callbacks_destroyed()); 321 ASSERT_EQ(1, callbacks_destroyed());
320 322
321 WaitForDownloadToFinish(); 323 WaitForDownloadToFinish();
322 ASSERT_EQ(1, add_provider_called()); 324 ASSERT_EQ(1, add_provider_called());
323 ASSERT_EQ(2, callbacks_destroyed()); 325 ASSERT_EQ(2, callbacks_destroyed());
324 ASSERT_TRUE(last_callback_template_url()); 326 ASSERT_TRUE(last_callback_template_url());
325 } 327 }
328
329 TEST_F(TemplateURLFetcherTest, PunycodeTest) {
330 base::string16 keyword(base::UTF8ToUTF16("\xd1\x82\xd0\xb5\xd1\x81\xd1\x82"));
331
332 test_util()->ChangeModelToLoadState();
333 ASSERT_FALSE(test_util()->model()->GetTemplateURLForKeyword(keyword));
334
335 std::string osdd_file_name("punycode_open_search.xml");
Matt Giuca 2015/07/17 04:13:11 This test is not necessary since we do not expect
alshabalin 2015/07/20 14:06:38 Done.
336 StartDownload(keyword, osdd_file_name,
337 TemplateURLFetcher::AUTODETECTED_PROVIDER, true);
338 WaitForDownloadToFinish();
339 const TemplateURL* t_url =
340 test_util()->model()->GetTemplateURLForKeyword(keyword);
341 EXPECT_EQ(keyword, t_url->short_name());
342 }
343
344 TEST_F(TemplateURLFetcherTest, UnicodeTest) {
Matt Giuca 2015/07/17 04:13:11 This is a good test! I'm kind of surprised that no
alshabalin 2015/07/20 14:06:38 Added a short_name() assertion to BasicAutodectedT
345 base::string16 keyword(base::UTF8ToUTF16("\xd1\x82\xd0\xb5\xd1\x81\xd1\x82"));
346
347 test_util()->ChangeModelToLoadState();
348 ASSERT_FALSE(test_util()->model()->GetTemplateURLForKeyword(keyword));
349
350 std::string osdd_file_name("unicode_open_search.xml");
351 StartDownload(keyword, osdd_file_name,
352 TemplateURLFetcher::AUTODETECTED_PROVIDER, true);
353 WaitForDownloadToFinish();
354 const TemplateURL* t_url =
355 test_util()->model()->GetTemplateURLForKeyword(keyword);
356 EXPECT_EQ(keyword, t_url->short_name());
Matt Giuca 2015/07/17 04:13:11 It's not clear why you expect short_name to equal
alshabalin 2015/07/20 14:06:37 Done. (Although I didn't introduce expected_short_
357 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698