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 "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 Loading... | |
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 base::ThreadRestrictions::SetIOAllowed(true); | |
78 ASSERT_FALSE( | |
79 ResourceBundle::GetSharedInstance().ReloadLocaleResources("he").empty()); | |
80 base::ThreadRestrictions::SetIOAllowed(false); | |
tony
2012/06/13 16:38:15
Nit: Can you use ScopedAllowIO here? You can put
Sheridan Rawlins
2012/06/13 20:10:34
When I do, I hit the pre-submit:
"New code should
| |
81 event->Signal(); | |
82 } | |
83 | |
72 void WebUIBidiCheckerBrowserTestRTL::SetUpOnMainThread() { | 84 void WebUIBidiCheckerBrowserTestRTL::SetUpOnMainThread() { |
73 WebUIBidiCheckerBrowserTest::SetUpOnMainThread(); | 85 WebUIBidiCheckerBrowserTest::SetUpOnMainThread(); |
74 FilePath pak_path; | 86 FilePath pak_path; |
75 app_locale_ = base::i18n::GetConfiguredLocale(); | 87 app_locale_ = base::i18n::GetConfiguredLocale(); |
76 ASSERT_TRUE(PathService::Get(base::FILE_MODULE, &pak_path)); | 88 ASSERT_TRUE(PathService::Get(base::FILE_MODULE, &pak_path)); |
77 pak_path = pak_path.DirName(); | 89 pak_path = pak_path.DirName(); |
78 pak_path = pak_path.AppendASCII("pseudo_locales"); | 90 pak_path = pak_path.AppendASCII("pseudo_locales"); |
79 pak_path = pak_path.AppendASCII("fake-bidi"); | 91 pak_path = pak_path.AppendASCII("fake-bidi"); |
80 pak_path = pak_path.ReplaceExtension(FILE_PATH_LITERAL("pak")); | 92 pak_path = pak_path.ReplaceExtension(FILE_PATH_LITERAL("pak")); |
81 ResourceBundle::GetSharedInstance().OverrideLocalePakForTest(pak_path); | 93 ResourceBundle::GetSharedInstance().OverrideLocalePakForTest(pak_path); |
82 ASSERT_FALSE( | 94 |
83 ResourceBundle::GetSharedInstance().ReloadLocaleResources("he").empty()); | 95 // Since synchronization isn't complete for the ResourceBundle class, reload |
96 // locale resources on the IO thread. | |
97 base::WaitableEvent event(true, false); | |
98 content::BrowserThread::PostTask( | |
99 content::BrowserThread::IO, FROM_HERE, | |
100 base::Bind(&WebUIBidiCheckerBrowserTestRTL::SetUpOnIOThread, &event)); | |
101 while (!event.IsSignaled()) | |
102 ui_test_utils::RunAllPendingInMessageLoop(); | |
103 | |
84 base::i18n::SetICUDefaultLocale("he"); | 104 base::i18n::SetICUDefaultLocale("he"); |
85 #if defined(OS_POSIX) && defined(TOOLKIT_GTK) | 105 #if defined(OS_POSIX) && defined(TOOLKIT_GTK) |
86 gtk_widget_set_default_direction(GTK_TEXT_DIR_RTL); | 106 gtk_widget_set_default_direction(GTK_TEXT_DIR_RTL); |
87 #endif | 107 #endif |
88 } | 108 } |
89 | 109 |
90 void WebUIBidiCheckerBrowserTestRTL::CleanUpOnMainThread() { | 110 void WebUIBidiCheckerBrowserTestRTL::CleanUpOnMainThread() { |
91 WebUIBidiCheckerBrowserTest::CleanUpOnMainThread(); | 111 WebUIBidiCheckerBrowserTest::CleanUpOnMainThread(); |
92 #if defined(OS_POSIX) && defined(TOOLKIT_GTK) | 112 #if defined(OS_POSIX) && defined(TOOLKIT_GTK) |
93 gtk_widget_set_default_direction(GTK_TEXT_DIR_LTR); | 113 gtk_widget_set_default_direction(GTK_TEXT_DIR_LTR); |
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
836 // chrome://history-frame | 856 // chrome://history-frame |
837 //============================== | 857 //============================== |
838 | 858 |
839 IN_PROC_BROWSER_TEST_F(WebUIBidiCheckerBrowserTestLTR, TestHistoryFrame) { | 859 IN_PROC_BROWSER_TEST_F(WebUIBidiCheckerBrowserTestLTR, TestHistoryFrame) { |
840 RunBidiCheckerOnPage(chrome::kChromeUIHistoryFrameURL); | 860 RunBidiCheckerOnPage(chrome::kChromeUIHistoryFrameURL); |
841 } | 861 } |
842 | 862 |
843 IN_PROC_BROWSER_TEST_F(WebUIBidiCheckerBrowserTestRTL, TestHistoryFrame) { | 863 IN_PROC_BROWSER_TEST_F(WebUIBidiCheckerBrowserTestRTL, TestHistoryFrame) { |
844 RunBidiCheckerOnPage(chrome::kChromeUIHistoryFrameURL); | 864 RunBidiCheckerOnPage(chrome::kChromeUIHistoryFrameURL); |
845 } | 865 } |
OLD | NEW |