OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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/command_line.h" | 5 #include "base/command_line.h" |
6 #include "chrome/browser/download/download_manager.h" | 6 #include "chrome/browser/download/download_manager.h" |
7 #include "chrome/browser/extensions/extension_service.h" | 7 #include "chrome/browser/extensions/extension_service.h" |
8 #include "chrome/browser/prefs/pref_service.h" | 8 #include "chrome/browser/prefs/pref_service.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
11 #include "chrome/browser/ui/browser_list.h" | 11 #include "chrome/browser/ui/browser_list.h" |
12 #include "chrome/browser/ui/browser_window.h" | 12 #include "chrome/browser/ui/browser_window.h" |
| 13 #include "chrome/browser/ui/find_bar/find_bar.h" |
| 14 #include "chrome/browser/ui/find_bar/find_bar_controller.h" |
13 #include "chrome/browser/ui/panels/panel.h" | 15 #include "chrome/browser/ui/panels/panel.h" |
14 #include "chrome/browser/ui/panels/panel_manager.h" | 16 #include "chrome/browser/ui/panels/panel_manager.h" |
15 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 17 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
16 #include "chrome/browser/web_applications/web_app.h" | 18 #include "chrome/browser/web_applications/web_app.h" |
17 #include "chrome/common/chrome_notification_types.h" | 19 #include "chrome/common/chrome_notification_types.h" |
18 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
19 #include "chrome/common/extensions/extension.h" | 21 #include "chrome/common/extensions/extension.h" |
20 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
21 #include "chrome/test/base/in_process_browser_test.h" | 23 #include "chrome/test/base/in_process_browser_test.h" |
22 #include "chrome/test/base/ui_test_utils.h" | 24 #include "chrome/test/base/ui_test_utils.h" |
23 #include "content/browser/net/url_request_mock_http_job.h" | 25 #include "content/browser/net/url_request_mock_http_job.h" |
24 #include "content/browser/tab_contents/test_tab_contents.h" | 26 #include "content/browser/tab_contents/test_tab_contents.h" |
25 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
26 | 28 |
| 29 #if defined(OS_MACOSX) |
| 30 #include "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h" |
| 31 #endif |
| 32 |
27 class PanelBrowserTest : public InProcessBrowserTest { | 33 class PanelBrowserTest : public InProcessBrowserTest { |
28 public: | 34 public: |
29 PanelBrowserTest() : InProcessBrowserTest() { } | 35 PanelBrowserTest() : InProcessBrowserTest() { |
| 36 #if defined(OS_MACOSX) |
| 37 FindBarBridge::disable_animations_during_testing_ = true; |
| 38 #endif |
| 39 } |
30 | 40 |
31 virtual void SetUpCommandLine(CommandLine* command_line) { | 41 virtual void SetUpCommandLine(CommandLine* command_line) { |
32 command_line->AppendSwitch(switches::kEnablePanels); | 42 command_line->AppendSwitch(switches::kEnablePanels); |
33 } | 43 } |
34 | 44 |
35 protected: | 45 protected: |
36 Panel* CreatePanel(const std::string& name, const gfx::Rect& bounds) { | 46 Panel* CreatePanel(const std::string& name, const gfx::Rect& bounds) { |
37 Browser* panel_browser = Browser::CreateForApp(Browser::TYPE_PANEL, | 47 Browser* panel_browser = Browser::CreateForApp(Browser::TYPE_PANEL, |
38 name, | 48 name, |
39 bounds, | 49 bounds, |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 gfx::Rect bounds = panel->GetBounds(); | 162 gfx::Rect bounds = panel->GetBounds(); |
153 EXPECT_GT(bounds.x(), 0); | 163 EXPECT_GT(bounds.x(), 0); |
154 EXPECT_GT(bounds.y(), 0); | 164 EXPECT_GT(bounds.y(), 0); |
155 EXPECT_GT(bounds.width(), 0); | 165 EXPECT_GT(bounds.width(), 0); |
156 EXPECT_GT(bounds.height(), 0); | 166 EXPECT_GT(bounds.height(), 0); |
157 | 167 |
158 panel->Close(); | 168 panel->Close(); |
159 EXPECT_EQ(0, panel_manager->num_panels()); | 169 EXPECT_EQ(0, panel_manager->num_panels()); |
160 } | 170 } |
161 | 171 |
| 172 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, FindBar) { |
| 173 Panel* panel = CreatePanel("PanelTest", gfx::Rect(0, 0, 400, 400)); |
| 174 Browser* browser = panel->browser(); |
| 175 browser->ShowFindBar(); |
| 176 ASSERT_TRUE(browser->GetFindBarController()->find_bar()->IsFindBarVisible()); |
| 177 panel->Close(); |
| 178 } |
| 179 |
162 // TODO(jianli): Investigate and enable it for Mac. | 180 // TODO(jianli): Investigate and enable it for Mac. |
163 #ifdef OS_MACOSX | 181 #ifdef OS_MACOSX |
164 #define MAYBE_CreatePanelOnOverflow DISABLED_CreatePanelOnOverflow | 182 #define MAYBE_CreatePanelOnOverflow DISABLED_CreatePanelOnOverflow |
165 #else | 183 #else |
166 #define MAYBE_CreatePanelOnOverflow CreatePanelOnOverflow | 184 #define MAYBE_CreatePanelOnOverflow CreatePanelOnOverflow |
167 #endif | 185 #endif |
168 | 186 |
169 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, MAYBE_CreatePanelOnOverflow) { | 187 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, MAYBE_CreatePanelOnOverflow) { |
170 TestCreatePanelOnOverflow(); | 188 TestCreatePanelOnOverflow(); |
171 } | 189 } |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 EXPECT_EQ(1, tabbed_browser->tab_count()); | 345 EXPECT_EQ(1, tabbed_browser->tab_count()); |
328 ASSERT_TRUE(tabbed_browser->window()->IsDownloadShelfVisible()); | 346 ASSERT_TRUE(tabbed_browser->window()->IsDownloadShelfVisible()); |
329 tabbed_browser->CloseWindow(); | 347 tabbed_browser->CloseWindow(); |
330 #endif | 348 #endif |
331 | 349 |
332 EXPECT_EQ(1, panel_browser->tab_count()); | 350 EXPECT_EQ(1, panel_browser->tab_count()); |
333 ASSERT_FALSE(panel_browser->window()->IsDownloadShelfVisible()); | 351 ASSERT_FALSE(panel_browser->window()->IsDownloadShelfVisible()); |
334 | 352 |
335 panel_browser->CloseWindow(); | 353 panel_browser->CloseWindow(); |
336 } | 354 } |
OLD | NEW |