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

Side by Side Diff: chrome/browser/ui/webui/bidi_checker_web_ui_test.cc

Issue 10546139: Do the ReloadLocaleResources() call on the IO thread to avoid synchronization issues. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove ui_test_utils:: for call within same namespace. Created 8 years, 6 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
« no previous file with comments | « chrome/browser/ui/webui/bidi_checker_web_ui_test.h ('k') | chrome/test/base/ui_test_utils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/browser/ui/webui/bidi_checker_web_ui_test.h" 5 #include "chrome/browser/ui/webui/bidi_checker_web_ui_test.h"
6 6
7 #include "base/base_paths.h" 7 #include "base/base_paths.h"
8 #include "base/i18n/rtl.h" 8 #include "base/i18n/rtl.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/synchronization/waitable_event.h"
10 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
11 #include "base/values.h" 12 #include "base/values.h"
12 #include "chrome/browser/autofill/autofill_common_test.h" 13 #include "chrome/browser/autofill/autofill_common_test.h"
13 #include "chrome/browser/autofill/autofill_profile.h" 14 #include "chrome/browser/autofill/autofill_profile.h"
14 #include "chrome/browser/autofill/personal_data_manager.h" 15 #include "chrome/browser/autofill/personal_data_manager.h"
15 #include "chrome/browser/autofill/personal_data_manager_factory.h" 16 #include "chrome/browser/autofill/personal_data_manager_factory.h"
16 #include "chrome/browser/history/history.h" 17 #include "chrome/browser/history/history.h"
17 #include "chrome/browser/prefs/pref_service.h" 18 #include "chrome/browser/prefs/pref_service.h"
18 #include "chrome/browser/prefs/session_startup_pref.h" 19 #include "chrome/browser/prefs/session_startup_pref.h"
19 #include "chrome/browser/profiles/profile.h" 20 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/browser/ui/browser.h" 21 #include "chrome/browser/ui/browser.h"
21 #include "chrome/common/url_constants.h" 22 #include "chrome/common/url_constants.h"
22 #include "chrome/test/base/ui_test_utils.h" 23 #include "chrome/test/base/ui_test_utils.h"
24 #include "content/public/browser/browser_thread.h"
23 #include "ui/base/resource/resource_bundle.h" 25 #include "ui/base/resource/resource_bundle.h"
24 26
25 #if defined(TOOLKIT_GTK) 27 #if defined(TOOLKIT_GTK)
26 #include <gtk/gtk.h> 28 #include <gtk/gtk.h>
27 #endif 29 #endif
28 30
29 static const FilePath::CharType* kWebUIBidiCheckerLibraryJS = 31 static const FilePath::CharType* kWebUIBidiCheckerLibraryJS =
30 FILE_PATH_LITERAL("third_party/bidichecker/bidichecker_packaged.js"); 32 FILE_PATH_LITERAL("third_party/bidichecker/bidichecker_packaged.js");
31 33
32 namespace { 34 namespace {
(...skipping 29 matching lines...) Expand all
62 void WebUIBidiCheckerBrowserTestLTR::RunBidiCheckerOnPage( 64 void WebUIBidiCheckerBrowserTestLTR::RunBidiCheckerOnPage(
63 const std::string& page_url) { 65 const std::string& page_url) {
64 WebUIBidiCheckerBrowserTest::RunBidiCheckerOnPage(page_url, false); 66 WebUIBidiCheckerBrowserTest::RunBidiCheckerOnPage(page_url, false);
65 } 67 }
66 68
67 void WebUIBidiCheckerBrowserTestRTL::RunBidiCheckerOnPage( 69 void WebUIBidiCheckerBrowserTestRTL::RunBidiCheckerOnPage(
68 const std::string& page_url) { 70 const std::string& page_url) {
69 WebUIBidiCheckerBrowserTest::RunBidiCheckerOnPage(page_url, true); 71 WebUIBidiCheckerBrowserTest::RunBidiCheckerOnPage(page_url, true);
70 } 72 }
71 73
74 // static
75 void WebUIBidiCheckerBrowserTestRTL::SetUpOnIOThread(
76 base::WaitableEvent* event) {
77 std::string locale;
78 {
79 base::ThreadRestrictions::ScopedAllowIO allow_io_scope;
80 locale.assign(
81 ResourceBundle::GetSharedInstance().ReloadLocaleResources("he"));
82 }
83 event->Signal();
84 ASSERT_FALSE(locale.empty());
85 }
86
72 void WebUIBidiCheckerBrowserTestRTL::SetUpOnMainThread() { 87 void WebUIBidiCheckerBrowserTestRTL::SetUpOnMainThread() {
73 WebUIBidiCheckerBrowserTest::SetUpOnMainThread(); 88 WebUIBidiCheckerBrowserTest::SetUpOnMainThread();
74 FilePath pak_path; 89 FilePath pak_path;
75 app_locale_ = base::i18n::GetConfiguredLocale(); 90 app_locale_ = base::i18n::GetConfiguredLocale();
76 ASSERT_TRUE(PathService::Get(base::FILE_MODULE, &pak_path)); 91 ASSERT_TRUE(PathService::Get(base::FILE_MODULE, &pak_path));
77 pak_path = pak_path.DirName(); 92 pak_path = pak_path.DirName();
78 pak_path = pak_path.AppendASCII("pseudo_locales"); 93 pak_path = pak_path.AppendASCII("pseudo_locales");
79 pak_path = pak_path.AppendASCII("fake-bidi"); 94 pak_path = pak_path.AppendASCII("fake-bidi");
80 pak_path = pak_path.ReplaceExtension(FILE_PATH_LITERAL("pak")); 95 pak_path = pak_path.ReplaceExtension(FILE_PATH_LITERAL("pak"));
81 ResourceBundle::GetSharedInstance().OverrideLocalePakForTest(pak_path); 96 ResourceBundle::GetSharedInstance().OverrideLocalePakForTest(pak_path);
82 ASSERT_FALSE( 97
83 ResourceBundle::GetSharedInstance().ReloadLocaleResources("he").empty()); 98 // Since synchronization isn't complete for the ResourceBundle class, reload
99 // locale resources on the IO thread.
100 base::WaitableEvent event(true, false);
101 content::BrowserThread::PostTask(
102 content::BrowserThread::IO, FROM_HERE,
103 base::Bind(&WebUIBidiCheckerBrowserTestRTL::SetUpOnIOThread,
104 base::Unretained(&event)));
105 ui_test_utils::WaitEventSignaled(&event);
Joao da Silva 2012/06/13 22:09:16 Why not PostTaskAndReply to IO? The posted task do
Sheridan Rawlins 2012/06/15 00:36:23 This was already committed, but I'll try this on a
106
84 base::i18n::SetICUDefaultLocale("he"); 107 base::i18n::SetICUDefaultLocale("he");
85 #if defined(OS_POSIX) && defined(TOOLKIT_GTK) 108 #if defined(OS_POSIX) && defined(TOOLKIT_GTK)
86 gtk_widget_set_default_direction(GTK_TEXT_DIR_RTL); 109 gtk_widget_set_default_direction(GTK_TEXT_DIR_RTL);
87 #endif 110 #endif
88 } 111 }
89 112
90 void WebUIBidiCheckerBrowserTestRTL::CleanUpOnMainThread() { 113 void WebUIBidiCheckerBrowserTestRTL::CleanUpOnMainThread() {
91 WebUIBidiCheckerBrowserTest::CleanUpOnMainThread(); 114 WebUIBidiCheckerBrowserTest::CleanUpOnMainThread();
92 #if defined(OS_POSIX) && defined(TOOLKIT_GTK) 115 #if defined(OS_POSIX) && defined(TOOLKIT_GTK)
93 gtk_widget_set_default_direction(GTK_TEXT_DIR_LTR); 116 gtk_widget_set_default_direction(GTK_TEXT_DIR_LTR);
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 // chrome://history-frame 859 // chrome://history-frame
837 //============================== 860 //==============================
838 861
839 IN_PROC_BROWSER_TEST_F(WebUIBidiCheckerBrowserTestLTR, TestHistoryFrame) { 862 IN_PROC_BROWSER_TEST_F(WebUIBidiCheckerBrowserTestLTR, TestHistoryFrame) {
840 RunBidiCheckerOnPage(chrome::kChromeUIHistoryFrameURL); 863 RunBidiCheckerOnPage(chrome::kChromeUIHistoryFrameURL);
841 } 864 }
842 865
843 IN_PROC_BROWSER_TEST_F(WebUIBidiCheckerBrowserTestRTL, TestHistoryFrame) { 866 IN_PROC_BROWSER_TEST_F(WebUIBidiCheckerBrowserTestRTL, TestHistoryFrame) {
844 RunBidiCheckerOnPage(chrome::kChromeUIHistoryFrameURL); 867 RunBidiCheckerOnPage(chrome::kChromeUIHistoryFrameURL);
845 } 868 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/bidi_checker_web_ui_test.h ('k') | chrome/test/base/ui_test_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698