| 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/i18n/rtl.h" | 5 #include "base/i18n/rtl.h" |
| 6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/common/chrome_paths.h" | 8 #include "chrome/common/chrome_paths.h" |
| 9 #include "chrome/common/extensions/manifest_tests/extension_manifest_test.h" | 9 #include "chrome/common/extensions/manifest_tests/extension_manifest_test.h" |
| 10 #include "chrome/common/extensions/manifest_url_handler.h" | 10 #include "chrome/common/extensions/manifest_url_handler.h" |
| 11 #include "extensions/common/extension.h" | 11 #include "extensions/common/extension.h" |
| 12 #include "extensions/common/manifest_constants.h" | 12 #include "extensions/common/manifest_constants.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include "ui/base/l10n/l10n_util.h" | 14 #include "ui/base/l10n/l10n_util.h" |
| 15 | 15 |
| 16 #if defined(TOOLKIT_GTK) | |
| 17 #include <gtk/gtk.h> | |
| 18 #endif | |
| 19 | |
| 20 namespace extensions { | 16 namespace extensions { |
| 21 | 17 |
| 22 namespace errors = manifest_errors; | 18 namespace errors = manifest_errors; |
| 23 namespace keys = manifest_keys; | 19 namespace keys = manifest_keys; |
| 24 | 20 |
| 25 class InitValueManifestTest : public ExtensionManifestTest { | 21 class InitValueManifestTest : public ExtensionManifestTest { |
| 26 }; | 22 }; |
| 27 | 23 |
| 28 TEST_F(InitValueManifestTest, InitFromValueInvalid) { | 24 TEST_F(InitValueManifestTest, InitFromValueInvalid) { |
| 29 Testcase testcases[] = { | 25 Testcase testcases[] = { |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 // We allow unknown API permissions, so this will be valid until we better | 130 // We allow unknown API permissions, so this will be valid until we better |
| 135 // distinguish between API and host permissions. | 131 // distinguish between API and host permissions. |
| 136 Testcase("init_valid_permissions_unknown.json") | 132 Testcase("init_valid_permissions_unknown.json") |
| 137 }; | 133 }; |
| 138 | 134 |
| 139 RunTestcases(testcases, arraysize(testcases), | 135 RunTestcases(testcases, arraysize(testcases), |
| 140 EXPECT_TYPE_SUCCESS); | 136 EXPECT_TYPE_SUCCESS); |
| 141 } | 137 } |
| 142 | 138 |
| 143 TEST_F(InitValueManifestTest, InitFromValueValidNameInRTL) { | 139 TEST_F(InitValueManifestTest, InitFromValueValidNameInRTL) { |
| 144 #if defined(TOOLKIT_GTK) | |
| 145 GtkTextDirection gtk_dir = gtk_widget_get_default_direction(); | |
| 146 gtk_widget_set_default_direction(GTK_TEXT_DIR_RTL); | |
| 147 #else | |
| 148 std::string locale = l10n_util::GetApplicationLocale(""); | 140 std::string locale = l10n_util::GetApplicationLocale(""); |
| 149 base::i18n::SetICUDefaultLocale("he"); | 141 base::i18n::SetICUDefaultLocale("he"); |
| 150 #endif | |
| 151 | 142 |
| 152 // No strong RTL characters in name. | 143 // No strong RTL characters in name. |
| 153 scoped_refptr<Extension> extension(LoadAndExpectSuccess( | 144 scoped_refptr<Extension> extension(LoadAndExpectSuccess( |
| 154 "init_valid_name_no_rtl.json")); | 145 "init_valid_name_no_rtl.json")); |
| 155 | 146 |
| 156 base::string16 localized_name(base::ASCIIToUTF16("Dictionary (by Google)")); | 147 base::string16 localized_name(base::ASCIIToUTF16("Dictionary (by Google)")); |
| 157 base::i18n::AdjustStringForLocaleDirection(&localized_name); | 148 base::i18n::AdjustStringForLocaleDirection(&localized_name); |
| 158 EXPECT_EQ(localized_name, base::UTF8ToUTF16(extension->name())); | 149 EXPECT_EQ(localized_name, base::UTF8ToUTF16(extension->name())); |
| 159 | 150 |
| 160 // Strong RTL characters in name. | 151 // Strong RTL characters in name. |
| 161 extension = LoadAndExpectSuccess("init_valid_name_strong_rtl.json"); | 152 extension = LoadAndExpectSuccess("init_valid_name_strong_rtl.json"); |
| 162 | 153 |
| 163 localized_name = base::WideToUTF16(L"Dictionary (\x05D1\x05D2" L" Google)"); | 154 localized_name = base::WideToUTF16(L"Dictionary (\x05D1\x05D2" L" Google)"); |
| 164 base::i18n::AdjustStringForLocaleDirection(&localized_name); | 155 base::i18n::AdjustStringForLocaleDirection(&localized_name); |
| 165 EXPECT_EQ(localized_name, base::UTF8ToUTF16(extension->name())); | 156 EXPECT_EQ(localized_name, base::UTF8ToUTF16(extension->name())); |
| 166 | 157 |
| 167 // Reset locale. | 158 // Reset locale. |
| 168 #if defined(TOOLKIT_GTK) | |
| 169 gtk_widget_set_default_direction(gtk_dir); | |
| 170 #else | |
| 171 base::i18n::SetICUDefaultLocale(locale); | 159 base::i18n::SetICUDefaultLocale(locale); |
| 172 #endif | |
| 173 } | 160 } |
| 174 | 161 |
| 175 } // namespace extensions | 162 } // namespace extensions |
| OLD | NEW |