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 | 5 |
6 #include <algorithm> | 6 #include <algorithm> |
7 #include <set> | 7 #include <set> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 // We only need to set the tl (target languages) dictionary. | 624 // We only need to set the tl (target languages) dictionary. |
625 scoped_ptr<DictionaryValue> target_languages_dict(new DictionaryValue); | 625 scoped_ptr<DictionaryValue> target_languages_dict(new DictionaryValue); |
626 for (size_t i = 0; i < language_list.size(); ++i) { | 626 for (size_t i = 0; i < language_list.size(); ++i) { |
627 // The value is ignored, we only use the key. | 627 // The value is ignored, we only use the key. |
628 target_languages_dict->Set(language_list[i], Value::CreateNullValue()); | 628 target_languages_dict->Set(language_list[i], Value::CreateNullValue()); |
629 } | 629 } |
630 | 630 |
631 DictionaryValue language_list_dict; | 631 DictionaryValue language_list_dict; |
632 language_list_dict.Set("tl", target_languages_dict.release()); | 632 language_list_dict.Set("tl", target_languages_dict.release()); |
633 std::string language_list_json_str; | 633 std::string language_list_json_str; |
634 base::JSONWriter::Write(&language_list_dict, false, &language_list_json_str); | 634 base::JSONWriter::Write(&language_list_dict, &language_list_json_str); |
635 std::string language_list_str("sl("); | 635 std::string language_list_str("sl("); |
636 language_list_str += language_list_json_str; | 636 language_list_str += language_list_json_str; |
637 language_list_str += ")"; | 637 language_list_str += ")"; |
638 return language_list_str; | 638 return language_list_str; |
639 } | 639 } |
640 | 640 |
641 // Test Language Code synonyms. | 641 // Test Language Code synonyms. |
642 TEST_F(TranslateManagerTest, LanguageCodeSynonyms) { | 642 TEST_F(TranslateManagerTest, LanguageCodeSynonyms) { |
643 // The current set of synonyms are {"nb", "no"}, {"he", "iw"}, {"jw", "jv"}. | 643 // The current set of synonyms are {"nb", "no"}, {"he", "iw"}, {"jw", "jv"}. |
644 | 644 |
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1430 NULL); | 1430 NULL); |
1431 // Now simulate the URL fetch. | 1431 // Now simulate the URL fetch. |
1432 SimulateTranslateScriptURLFetch(true); | 1432 SimulateTranslateScriptURLFetch(true); |
1433 // Now the message should have been sent. | 1433 // Now the message should have been sent. |
1434 int page_id = 0; | 1434 int page_id = 0; |
1435 std::string original_lang, target_lang; | 1435 std::string original_lang, target_lang; |
1436 EXPECT_TRUE(GetTranslateMessage(&page_id, &original_lang, &target_lang)); | 1436 EXPECT_TRUE(GetTranslateMessage(&page_id, &original_lang, &target_lang)); |
1437 EXPECT_EQ("es", original_lang); | 1437 EXPECT_EQ("es", original_lang); |
1438 EXPECT_EQ("en", target_lang); | 1438 EXPECT_EQ("en", target_lang); |
1439 } | 1439 } |
OLD | NEW |