OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_path.h" | 5 #include "base/file_path.h" |
6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
7 #include "base/task.h" | 7 #include "base/task.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "chrome/browser/dom_ui/dom_ui.h" | 10 #include "chrome/browser/dom_ui/dom_ui.h" |
11 #include "chrome/browser/tab_contents/navigation_controller.h" | 11 #include "chrome/browser/tab_contents/navigation_controller.h" |
12 #include "chrome/browser/tab_contents/tab_contents.h" | 12 #include "chrome/browser/tab_contents/tab_contents.h" |
13 #include "chrome/browser/views/html_dialog_view.h" | 13 #include "chrome/browser/views/html_dialog_view.h" |
14 #include "chrome/common/chrome_paths.h" | 14 #include "chrome/common/chrome_paths.h" |
15 #include "chrome/common/notification_registrar.h" | 15 #include "chrome/common/notification_registrar.h" |
16 #include "chrome/common/url_constants.h" | 16 #include "chrome/common/url_constants.h" |
17 #include "chrome/test/in_process_browser_test.h" | 17 #include "chrome/test/in_process_browser_test.h" |
18 #include "chrome/test/ui_test_utils.h" | 18 #include "chrome/test/ui_test_utils.h" |
| 19 #include "net/test/test_server.h" |
19 | 20 |
20 namespace { | 21 namespace { |
21 | 22 |
22 typedef DOMElementProxy::By By; | 23 typedef DOMElementProxy::By By; |
23 | 24 |
24 class FileBrowseBrowserTest : public InProcessBrowserTest { | 25 class FileBrowseBrowserTest : public InProcessBrowserTest { |
25 public: | 26 public: |
26 FileBrowseBrowserTest() { | 27 FileBrowseBrowserTest() { |
27 EnableDOMAutomation(); | 28 EnableDOMAutomation(); |
28 } | 29 } |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 | 99 |
99 private: | 100 private: |
100 NotificationRegistrar registrar_; | 101 NotificationRegistrar registrar_; |
101 TabContents* file_browse_tab_; | 102 TabContents* file_browse_tab_; |
102 bool is_waiting_; | 103 bool is_waiting_; |
103 | 104 |
104 DISALLOW_COPY_AND_ASSIGN(FileBrowseUiObserver); | 105 DISALLOW_COPY_AND_ASSIGN(FileBrowseUiObserver); |
105 }; | 106 }; |
106 | 107 |
107 IN_PROC_BROWSER_TEST_F(FileBrowseBrowserTest, InputFileTriggerFileBrowse) { | 108 IN_PROC_BROWSER_TEST_F(FileBrowseBrowserTest, InputFileTriggerFileBrowse) { |
108 HTTPTestServer* server = StartHTTPServer(); | 109 net::HTTPTestServer* server = StartHTTPServer(); |
109 ui_test_utils::NavigateToURL(browser(), | 110 ui_test_utils::NavigateToURL(browser(), |
110 server->TestServerPage("files/input_file.html")); | 111 server->TestServerPage("files/input_file.html")); |
111 | 112 |
112 DOMElementProxyRef doc = ui_test_utils::GetActiveDOMDocument(browser()); | 113 DOMElementProxyRef doc = ui_test_utils::GetActiveDOMDocument(browser()); |
113 | 114 |
114 DOMElementProxyRef input_file = doc->FindElement(By::Selectors(".single")); | 115 DOMElementProxyRef input_file = doc->FindElement(By::Selectors(".single")); |
115 ASSERT_TRUE(input_file); | 116 ASSERT_TRUE(input_file); |
116 | 117 |
117 // Creates FileBrowseUiObserver before we click. | 118 // Creates FileBrowseUiObserver before we click. |
118 FileBrowseUiObserver observer; | 119 FileBrowseUiObserver observer; |
119 | 120 |
120 // Click on the input control. This should bring up the FileBrowseUI. | 121 // Click on the input control. This should bring up the FileBrowseUI. |
121 input_file->Click(); | 122 input_file->Click(); |
122 | 123 |
123 observer.WaitForFileBrowseLoad(); | 124 observer.WaitForFileBrowseLoad(); |
124 DOMUI* file_browser_ui = observer.file_browse_ui(); | 125 DOMUI* file_browser_ui = observer.file_browse_ui(); |
125 ASSERT_TRUE(file_browser_ui); | 126 ASSERT_TRUE(file_browser_ui); |
126 | 127 |
127 file_browser_ui->CallJavascriptFunction(L"dialogCancelClick"); | 128 file_browser_ui->CallJavascriptFunction(L"dialogCancelClick"); |
128 | 129 |
129 observer.WaitForFileBrowseClose(); | 130 observer.WaitForFileBrowseClose(); |
130 } | 131 } |
131 | 132 |
132 } // namespace | 133 } // namespace |
OLD | NEW |