OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/ui/webui/BidiCheckerWebUITest.h" | |
6 | |
7 #include "base/base_paths.h" | |
8 #include "base/path_service.h" | |
9 #include "base/utf_string_conversions.h" | |
10 #include "base/values.h" | |
11 #include "chrome/browser/autofill/autofill_common_test.h" | |
12 #include "chrome/browser/autofill/autofill_profile.h" | |
13 #include "chrome/browser/autofill/personal_data_manager.h" | |
14 #include "chrome/browser/history/history.h" | |
15 #include "chrome/browser/profiles/profile.h" | |
16 #include "chrome/browser/ui/browser.h" | |
17 #include "chrome/common/url_constants.h" | |
18 #include "chrome/test/base/ui_test_utils.h" | |
19 | |
20 static const FilePath::CharType* kWebUIBidiCheckerLibraryJS = | |
21 FILE_PATH_LITERAL("third_party/bidichecker/bidichecker_packaged.js"); | |
22 | |
23 namespace { | |
24 FilePath WebUIBidiCheckerLibraryJSPath() { | |
25 FilePath src_root; | |
26 if (!PathService::Get(base::DIR_SOURCE_ROOT, &src_root)) | |
27 LOG(ERROR) << "Couldn't find source root"; | |
28 return src_root.Append(kWebUIBidiCheckerLibraryJS); | |
29 } | |
30 } | |
31 | |
32 static const FilePath::CharType* kBidiCheckerTestsJS = | |
33 FILE_PATH_LITERAL("bidichecker_tests.js"); | |
34 | |
35 WebUIBidiCheckerBrowserTest::~WebUIBidiCheckerBrowserTest() {} | |
36 | |
37 WebUIBidiCheckerBrowserTest::WebUIBidiCheckerBrowserTest() {} | |
38 | |
39 void WebUIBidiCheckerBrowserTest::SetUpInProcessBrowserTestFixture() { | |
40 WebUIBrowserTest::SetUpInProcessBrowserTestFixture(); | |
41 WebUIBrowserTest::AddLibrary(WebUIBidiCheckerLibraryJSPath()); | |
42 WebUIBrowserTest::AddLibrary(FilePath(kBidiCheckerTestsJS)); | |
43 } | |
44 | |
45 void WebUIBidiCheckerBrowserTest::RunBidiCheckerOnPage(const char pageURL[], | |
46 bool isRTL) { | |
47 ui_test_utils::NavigateToURL(browser(), GURL(pageURL)); | |
48 ASSERT_TRUE(RunJavascriptTest("runBidiChecker", | |
49 Value::CreateStringValue(pageURL), | |
50 Value::CreateBooleanValue(isRTL))); | |
51 } | |
52 | |
53 IN_PROC_BROWSER_TEST_F(WebUIBidiCheckerBrowserTest, TestMainHistoryPageLTR) { | |
54 HistoryService* history_service = | |
55 browser()->profile()->GetHistoryService(Profile::IMPLICIT_ACCESS); | |
56 const GURL history_url = GURL("http://www.ynet.co.il"); | |
57 history_service->AddPage(history_url, history::SOURCE_BROWSED); | |
58 string16 title; | |
59 ASSERT_TRUE(UTF8ToUTF16("\xD7\x91\xD7\x93\xD7\x99\xD7\xA7\xD7\x94\x21", | |
60 12, | |
61 &title)); | |
62 history_service->SetPageTitle(history_url, title); | |
63 RunBidiCheckerOnPage(chrome::kChromeUIHistoryURL, false); | |
64 } | |
65 | |
66 IN_PROC_BROWSER_TEST_F(WebUIBidiCheckerBrowserTest, TestAboutPageLTR) {\ | |
67 RunBidiCheckerOnPage(chrome::kChromeUIAboutURL, false);\ | |
68 } | |
69 | |
70 // Times out. http://code.google.com/p/chromium/issues/detail?id=82896 | |
71 IN_PROC_BROWSER_TEST_F(WebUIBidiCheckerBrowserTest, | |
72 DISABLED_TestBookmarksPageLTR) {\ | |
73 RunBidiCheckerOnPage(chrome::kChromeUIBookmarksURL, false);\ | |
74 } | |
75 | |
76 IN_PROC_BROWSER_TEST_F(WebUIBidiCheckerBrowserTest, TestBugReportPageLTR) {\ | |
77 RunBidiCheckerOnPage(chrome::kChromeUIBugReportURL, false);\ | |
78 } | |
79 | |
80 IN_PROC_BROWSER_TEST_F(WebUIBidiCheckerBrowserTest, TestCrashesPageLTR) {\ | |
81 RunBidiCheckerOnPage(chrome::kChromeUICrashesURL, false);\ | |
82 } | |
83 | |
84 IN_PROC_BROWSER_TEST_F(WebUIBidiCheckerBrowserTest, TestDownloadsPageLTR) {\ | |
85 RunBidiCheckerOnPage(chrome::kChromeUIDownloadsURL, false);\ | |
86 } | |
87 | |
88 IN_PROC_BROWSER_TEST_F(WebUIBidiCheckerBrowserTest, TestNewTabPageLTR) {\ | |
89 RunBidiCheckerOnPage(chrome::kChromeUINewTabURL, false);\ | |
90 } | |
91 | |
92 IN_PROC_BROWSER_TEST_F(WebUIBidiCheckerBrowserTest, TestPluginsPageLTR) {\ | |
93 RunBidiCheckerOnPage(chrome::kChromeUIPluginsURL, false);\ | |
94 } | |
95 | |
96 IN_PROC_BROWSER_TEST_F(WebUIBidiCheckerBrowserTest, TestSettingsPageLTR) {\ | |
97 RunBidiCheckerOnPage(chrome::kChromeUISettingsURL, false);\ | |
98 } | |
99 | |
100 IN_PROC_BROWSER_TEST_F(WebUIBidiCheckerBrowserTest, | |
101 TestSettingsAutofillPageLTR) { | |
102 std::string url(chrome::kChromeUISettingsURL); | |
103 url += std::string(chrome::kAutofillSubPage); | |
104 | |
105 autofill_test::DisableSystemServices(browser()->profile()); | |
106 AutofillProfile profile; | |
107 autofill_test::SetProfileInfo( | |
108 &profile, | |
109 "\xD7\x9E\xD7\xA9\xD7\x94", | |
110 "\xD7\x91", | |
111 "\xD7\x9B\xD7\x94\xD7\x9F", | |
112 "moshe.b.cohen@biditest.com", | |
113 "\xD7\x91\xD7\x93\xD7\x99\xD7\xA7\xD7\x94\x20\xD7\x91\xD7\xA2\xD7\x9E", | |
114 "\xD7\x93\xD7\xA8\xD7\x9A\x20\xD7\x9E\xD7\xA0\xD7\x97\xD7\x9D\x20\xD7\x91\
xD7\x92\xD7\x99\xD7\x9F\x20\x32\x33", | |
115 "\xD7\xA7\xD7\x95\xD7\x9E\xD7\x94\x20\x32\x36", | |
116 "\xD7\xAA\xD7\x9C\x20\xD7\x90\xD7\x91\xD7\x99\xD7\x91", | |
117 "", | |
118 "66183", | |
119 "\xD7\x99\xD7\xA9\xD7\xA8\xD7\x90\xD7\x9C", | |
120 "0000", | |
121 "0000"); | |
122 | |
123 PersonalDataManager* personal_data_manager = | |
124 browser()->profile()->GetPersonalDataManager(); | |
125 ASSERT_TRUE(personal_data_manager); | |
126 | |
127 personal_data_manager->AddProfile(profile); | |
128 | |
129 RunBidiCheckerOnPage(url.c_str(), false); | |
130 } | |
OLD | NEW |