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

Side by Side Diff: chrome/browser/extensions/api/i18n/i18n_apitest.cc

Issue 18332014: Move Copy* into the base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: windows Created 7 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 | Annotate | Revision Log
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 "base/file_util.h" 5 #include "base/file_util.h"
6 #include "base/files/file_path.h" 6 #include "base/files/file_path.h"
7 #include "base/files/scoped_temp_dir.h" 7 #include "base/files/scoped_temp_dir.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/extensions/extension_apitest.h" 9 #include "chrome/browser/extensions/extension_apitest.h"
10 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
11 #include "chrome/common/extensions/extension.h" 11 #include "chrome/common/extensions/extension.h"
12 #include "chrome/test/base/ui_test_utils.h" 12 #include "chrome/test/base/ui_test_utils.h"
13 #include "net/test/embedded_test_server/embedded_test_server.h" 13 #include "net/test/embedded_test_server/embedded_test_server.h"
14 14
15 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, I18N) { 15 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, I18N) {
16 ASSERT_TRUE(StartEmbeddedTestServer()); 16 ASSERT_TRUE(StartEmbeddedTestServer());
17 ASSERT_TRUE(RunExtensionTest("i18n")) << message_; 17 ASSERT_TRUE(RunExtensionTest("i18n")) << message_;
18 } 18 }
19 19
20 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, I18NUpdate) { 20 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, I18NUpdate) {
21 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 21 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
22 // Create an Extension whose messages.json file will be updated. 22 // Create an Extension whose messages.json file will be updated.
23 base::ScopedTempDir extension_dir; 23 base::ScopedTempDir extension_dir;
24 ASSERT_TRUE(extension_dir.CreateUniqueTempDir()); 24 ASSERT_TRUE(extension_dir.CreateUniqueTempDir());
25 file_util::CopyFile( 25 base::CopyFile(
26 test_data_dir_.AppendASCII("i18nUpdate") 26 test_data_dir_.AppendASCII("i18nUpdate")
27 .AppendASCII("manifest.json"), 27 .AppendASCII("manifest.json"),
28 extension_dir.path().AppendASCII("manifest.json")); 28 extension_dir.path().AppendASCII("manifest.json"));
29 file_util::CopyFile( 29 base::CopyFile(
30 test_data_dir_.AppendASCII("i18nUpdate") 30 test_data_dir_.AppendASCII("i18nUpdate")
31 .AppendASCII("contentscript.js"), 31 .AppendASCII("contentscript.js"),
32 extension_dir.path().AppendASCII("contentscript.js")); 32 extension_dir.path().AppendASCII("contentscript.js"));
33 file_util::CopyDirectory( 33 base::CopyDirectory(
34 test_data_dir_.AppendASCII("i18nUpdate") 34 test_data_dir_.AppendASCII("i18nUpdate")
35 .AppendASCII("_locales"), 35 .AppendASCII("_locales"),
36 extension_dir.path().AppendASCII("_locales"), 36 extension_dir.path().AppendASCII("_locales"),
37 true); 37 true);
38 38
39 const extensions::Extension* extension = LoadExtension(extension_dir.path()); 39 const extensions::Extension* extension = LoadExtension(extension_dir.path());
40 40
41 ResultCatcher catcher; 41 ResultCatcher catcher;
42 42
43 // Test that the messages.json file is loaded and the i18n message is loaded. 43 // Test that the messages.json file is loaded and the i18n message is loaded.
44 ui_test_utils::NavigateToURL( 44 ui_test_utils::NavigateToURL(
45 browser(), 45 browser(),
46 embedded_test_server()->GetURL("/extensions/test_file.html")); 46 embedded_test_server()->GetURL("/extensions/test_file.html"));
47 EXPECT_TRUE(catcher.GetNextResult()); 47 EXPECT_TRUE(catcher.GetNextResult());
48 48
49 string16 title; 49 string16 title;
50 ui_test_utils::GetCurrentTabTitle(browser(), &title); 50 ui_test_utils::GetCurrentTabTitle(browser(), &title);
51 EXPECT_EQ(std::string("FIRSTMESSAGE"), UTF16ToUTF8(title)); 51 EXPECT_EQ(std::string("FIRSTMESSAGE"), UTF16ToUTF8(title));
52 52
53 // Change messages.json file and reload extension. 53 // Change messages.json file and reload extension.
54 file_util::CopyFile( 54 base::CopyFile(
55 test_data_dir_.AppendASCII("i18nUpdate") 55 test_data_dir_.AppendASCII("i18nUpdate")
56 .AppendASCII("messages2.json"), 56 .AppendASCII("messages2.json"),
57 extension_dir.path().AppendASCII("_locales/en/messages.json")); 57 extension_dir.path().AppendASCII("_locales/en/messages.json"));
58 ReloadExtension(extension->id()); 58 ReloadExtension(extension->id());
59 59
60 // Check that the i18n message is also changed. 60 // Check that the i18n message is also changed.
61 ui_test_utils::NavigateToURL( 61 ui_test_utils::NavigateToURL(
62 browser(), 62 browser(),
63 embedded_test_server()->GetURL("/extensions/test_file.html")); 63 embedded_test_server()->GetURL("/extensions/test_file.html"));
64 EXPECT_TRUE(catcher.GetNextResult()); 64 EXPECT_TRUE(catcher.GetNextResult());
65 65
66 ui_test_utils::GetCurrentTabTitle(browser(), &title); 66 ui_test_utils::GetCurrentTabTitle(browser(), &title);
67 EXPECT_EQ(std::string("SECONDMESSAGE"), UTF16ToUTF8(title)); 67 EXPECT_EQ(std::string("SECONDMESSAGE"), UTF16ToUTF8(title));
68 } 68 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698