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. |
Devlin
2013/02/27 23:10:41
Newline after the license
Patrick Riordan
2013/03/01 17:29:22
Done.
| |
4 | 4 #include "base/file_util.h" |
5 #include "base/utf_string_conversions.h" | |
5 #include "chrome/browser/extensions/extension_apitest.h" | 6 #include "chrome/browser/extensions/extension_apitest.h" |
7 #include "chrome/test/base/ui_test_utils.h" | |
Devlin
2013/02/27 23:10:41
We have an "include what you use" rule (i.e., anyt
Patrick Riordan
2013/03/01 17:29:22
Changed to include everything used.
| |
6 | 8 |
7 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, I18N) { | 9 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, I18N) { |
8 ASSERT_TRUE(StartTestServer()); | 10 ASSERT_TRUE(StartTestServer()); |
9 ASSERT_TRUE(RunExtensionTest("i18n")) << message_; | 11 ASSERT_TRUE(RunExtensionTest("i18n")) << message_; |
10 } | 12 } |
13 | |
14 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, I18NUpdate) { | |
15 ASSERT_TRUE(StartTestServer()); | |
16 // Create an Extension whose messages.json file will be updated. | |
17 base::FilePath extension_dir; | |
18 file_util::CreateNewTempDirectory("", &extension_dir); | |
19 file_util::CopyFile( | |
20 test_data_dir_.AppendASCII("i18nUpdate") | |
21 .AppendASCII("manifest.json"), | |
22 extension_dir.AppendASCII("manifest.json")); | |
23 file_util::CopyFile( | |
24 test_data_dir_.AppendASCII("i18nUpdate") | |
25 .AppendASCII("contentscript.js"), | |
26 extension_dir.AppendASCII("contentscript.js")); | |
27 file_util::CopyDirectory( | |
28 test_data_dir_.AppendASCII("i18nUpdate") | |
29 .AppendASCII("_locales"), | |
30 extension_dir.AppendASCII("_locales"), | |
31 true); | |
32 | |
33 const extensions::Extension* extension = LoadExtension(extension_dir); | |
34 | |
35 ResultCatcher catcher; | |
36 | |
37 // Test that the messages.json file is loaded and the i18n message is loaded. | |
38 ui_test_utils::NavigateToURL( | |
39 browser(), test_server()->GetURL("file/extensions/test_file.html")); | |
40 EXPECT_TRUE(catcher.GetNextResult()); | |
41 | |
42 string16 title; | |
43 ui_test_utils::GetCurrentTabTitle(browser(), &title); | |
44 EXPECT_EQ(std::string("FIRSTMESSAGE"), UTF16ToUTF8(title)); | |
45 | |
46 // Change messages.json file and reload extension. | |
47 file_util::CopyFile( | |
48 test_data_dir_.AppendASCII("i18nUpdate") | |
49 .AppendASCII("messages2.json"), | |
50 extension_dir.AppendASCII("_locales/en/messages.json")); | |
51 ReloadExtension(extension->id()); | |
52 | |
53 // Check that the i18n message is also changed. | |
54 ui_test_utils::NavigateToURL( | |
55 browser(), test_server()->GetURL("file/extensions/test_file.html")); | |
56 EXPECT_TRUE(catcher.GetNextResult()); | |
57 | |
58 ui_test_utils::GetCurrentTabTitle(browser(), &title); | |
59 EXPECT_EQ(std::string("SECONDMESSAGE"), UTF16ToUTF8(title)); | |
60 } | |
OLD | NEW |