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

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

Issue 12319073: Delete the extensions i18n message map when extension unload is received. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed "", windows should be happy now Created 7 years, 9 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 "base/file_util.h"
6 #include "base/files/file_path.h"
7 #include "base/utf_string_conversions.h"
5 #include "chrome/browser/extensions/extension_apitest.h" 8 #include "chrome/browser/extensions/extension_apitest.h"
9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/common/extensions/extension.h"
11 #include "chrome/test/base/ui_test_utils.h"
12 #include "net/test/test_server.h"
6 13
7 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, I18N) { 14 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, I18N) {
8 ASSERT_TRUE(StartTestServer()); 15 ASSERT_TRUE(StartTestServer());
9 ASSERT_TRUE(RunExtensionTest("i18n")) << message_; 16 ASSERT_TRUE(RunExtensionTest("i18n")) << message_;
10 } 17 }
18
19 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, I18NUpdate) {
20 ASSERT_TRUE(StartTestServer());
21 // Create an Extension whose messages.json file will be updated.
22 base::FilePath extension_dir;
23 file_util::CreateNewTempDirectory(base::FilePath::StringType(),
Yoyo Zhou 2013/03/08 22:17:50 Use ScopedTempDir so your temp directory is delete
Patrick Riordan 2013/03/11 17:32:42 Done.
24 &extension_dir);
25 file_util::CopyFile(
26 test_data_dir_.AppendASCII("i18nUpdate")
27 .AppendASCII("manifest.json"),
28 extension_dir.AppendASCII("manifest.json"));
29 file_util::CopyFile(
30 test_data_dir_.AppendASCII("i18nUpdate")
31 .AppendASCII("contentscript.js"),
32 extension_dir.AppendASCII("contentscript.js"));
33 file_util::CopyDirectory(
34 test_data_dir_.AppendASCII("i18nUpdate")
35 .AppendASCII("_locales"),
36 extension_dir.AppendASCII("_locales"),
37 true);
38
39 const extensions::Extension* extension = LoadExtension(extension_dir);
40
41 ResultCatcher catcher;
42
43 // Test that the messages.json file is loaded and the i18n message is loaded.
44 ui_test_utils::NavigateToURL(
45 browser(), test_server()->GetURL("file/extensions/test_file.html"));
46 EXPECT_TRUE(catcher.GetNextResult());
47
48 string16 title;
49 ui_test_utils::GetCurrentTabTitle(browser(), &title);
50 EXPECT_EQ(std::string("FIRSTMESSAGE"), UTF16ToUTF8(title));
51
52 // Change messages.json file and reload extension.
53 file_util::CopyFile(
54 test_data_dir_.AppendASCII("i18nUpdate")
55 .AppendASCII("messages2.json"),
56 extension_dir.AppendASCII("_locales/en/messages.json"));
57 ReloadExtension(extension->id());
58
59 // Check that the i18n message is also changed.
60 ui_test_utils::NavigateToURL(
61 browser(), test_server()->GetURL("file/extensions/test_file.html"));
62 EXPECT_TRUE(catcher.GetNextResult());
63
64 ui_test_utils::GetCurrentTabTitle(browser(), &title);
65 EXPECT_EQ(std::string("SECONDMESSAGE"), UTF16ToUTF8(title));
66 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698