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 "base/i18n/time_formatting.h" | 6 #include "base/i18n/time_formatting.h" |
7 #include "chrome/browser/extensions/extension_service.h" | 7 #include "chrome/browser/extensions/extension_service.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
10 #include "chrome/browser/ui/browser_window.h" | 10 #include "chrome/browser/ui/browser_window.h" |
11 #include "chrome/browser/ui/panels/about_panel_bubble.h" | |
12 #include "chrome/browser/ui/panels/panel.h" | 11 #include "chrome/browser/ui/panels/panel.h" |
13 #include "chrome/browser/ui/panels/panel_browser_frame_view.h" | 12 #include "chrome/browser/ui/panels/panel_browser_frame_view.h" |
14 #include "chrome/browser/ui/panels/panel_browser_view.h" | 13 #include "chrome/browser/ui/panels/panel_browser_view.h" |
15 #include "chrome/browser/web_applications/web_app.h" | 14 #include "chrome/browser/web_applications/web_app.h" |
16 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
17 #include "chrome/common/extensions/extension.h" | 16 #include "chrome/common/extensions/extension.h" |
18 #include "chrome/test/in_process_browser_test.h" | 17 #include "chrome/test/in_process_browser_test.h" |
19 #include "grit/generated_resources.h" | 18 #include "grit/generated_resources.h" |
20 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
21 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
22 #include "ui/base/animation/slide_animation.h" | 21 #include "ui/base/animation/slide_animation.h" |
23 #include "views/controls/button/image_button.h" | 22 #include "views/controls/button/image_button.h" |
23 #include "views/controls/button/menu_button.h" | |
24 #include "views/controls/image_view.h" | 24 #include "views/controls/image_view.h" |
25 #include "views/controls/label.h" | 25 #include "views/controls/label.h" |
26 #include "views/controls/link.h" | 26 #include "views/controls/link.h" |
27 #include "views/controls/menu/menu_2.h" | |
27 #include "views/controls/textfield/textfield.h" | 28 #include "views/controls/textfield/textfield.h" |
28 | 29 |
29 class PanelBrowserViewTest : public InProcessBrowserTest { | 30 class PanelBrowserViewTest : public InProcessBrowserTest { |
30 public: | 31 public: |
31 PanelBrowserViewTest() : InProcessBrowserTest() { } | 32 PanelBrowserViewTest() : InProcessBrowserTest() { } |
32 | 33 |
33 virtual void SetUpCommandLine(CommandLine* command_line) { | 34 virtual void SetUpCommandLine(CommandLine* command_line) { |
34 command_line->AppendSwitch(switches::kEnablePanels); | 35 command_line->AppendSwitch(switches::kEnablePanels); |
35 } | 36 } |
36 | 37 |
37 protected: | 38 protected: |
39 struct MenuItem { | |
40 int id; | |
41 bool enabled; | |
42 }; | |
43 | |
38 class MockMouseWatcher : public PanelBrowserFrameView::MouseWatcher { | 44 class MockMouseWatcher : public PanelBrowserFrameView::MouseWatcher { |
39 public: | 45 public: |
40 explicit MockMouseWatcher(PanelBrowserFrameView* view) | 46 explicit MockMouseWatcher(PanelBrowserFrameView* view) |
41 : PanelBrowserFrameView::MouseWatcher(view), | 47 : PanelBrowserFrameView::MouseWatcher(view), |
42 is_cursor_in_view_(false) { | 48 is_cursor_in_view_(false) { |
43 } | 49 } |
44 | 50 |
45 virtual bool IsCursorInViewBounds() const { | 51 virtual bool IsCursorInViewBounds() const { |
46 return is_cursor_in_view_; | 52 return is_cursor_in_view_; |
47 } | 53 } |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
154 // Repeat the mouse events to this panel. | 160 // Repeat the mouse events to this panel. |
155 browser_views[swapped_index]->OnTitleBarMousePressed(pressed); | 161 browser_views[swapped_index]->OnTitleBarMousePressed(pressed); |
156 browser_views[swapped_index]->OnTitleBarMouseDragged(dragged); | 162 browser_views[swapped_index]->OnTitleBarMouseDragged(dragged); |
157 browser_views[swapped_index]->OnTitleBarMouseReleased(released); | 163 browser_views[swapped_index]->OnTitleBarMouseReleased(released); |
158 for (size_t i = 0; i < num_browser_views; ++i) { | 164 for (size_t i = 0; i < num_browser_views; ++i) { |
159 EXPECT_EQ(initial_bounds[i], | 165 EXPECT_EQ(initial_bounds[i], |
160 browser_views[i]->panel()->GetRestoredBounds()); | 166 browser_views[i]->panel()->GetRestoredBounds()); |
161 } | 167 } |
162 } | 168 } |
163 } | 169 } |
170 | |
171 void ValidateWrenchMenuItems(ui::SimpleMenuModel* wrench_menu_contents, | |
jennb
2011/06/01 22:24:14
which parameter is the expected menu items?
jianli
2011/06/01 23:23:38
Renamed items to prefix with expected.
| |
172 size_t count, | |
173 MenuItem* items) { | |
174 ASSERT_TRUE(wrench_menu_contents); | |
175 EXPECT_EQ(static_cast<int>(count), wrench_menu_contents->GetItemCount()); | |
176 for (size_t i = 0; i < count; ++i) { | |
177 if (items[i].id == -1) { | |
178 EXPECT_EQ(ui::MenuModel::TYPE_SEPARATOR, | |
179 wrench_menu_contents->GetTypeAt(i)); | |
180 } else { | |
181 EXPECT_EQ(items[i].id, wrench_menu_contents->GetCommandIdAt(i)); | |
182 EXPECT_EQ(items[i].enabled, wrench_menu_contents->IsEnabledAt(i)); | |
183 } | |
184 } | |
185 } | |
186 | |
187 void TestCreateWrenchMenuForExtension(const FilePath::StringType& path, | |
188 Extension::Location location, | |
189 const std::string& homepage_url, | |
190 const std::string& options_page) { | |
191 // Creates a testing extension. | |
192 #if defined(OS_WIN) | |
193 FilePath full_path(FILE_PATH_LITERAL("c:\\")); | |
194 #else | |
195 FilePath full_path(FILE_PATH_LITERAL("/")); | |
196 #endif | |
197 full_path.Append(path); | |
198 DictionaryValue input_value; | |
199 input_value.SetString(extension_manifest_keys::kVersion, "1.0.0.0"); | |
200 input_value.SetString(extension_manifest_keys::kName, "Sample Extension"); | |
201 if (!homepage_url.empty()) { | |
202 input_value.SetString(extension_manifest_keys::kHomepageURL, | |
203 homepage_url); | |
204 } | |
205 if (!options_page.empty()) { | |
206 input_value.SetString(extension_manifest_keys::kOptionsPage, | |
207 options_page); | |
208 } | |
209 std::string error; | |
210 scoped_refptr<Extension> extension = Extension::Create( | |
211 full_path, location, input_value, Extension::STRICT_ERROR_CHECKS, | |
212 &error); | |
213 ASSERT_TRUE(extension.get()); | |
214 EXPECT_STREQ("", error.c_str()); | |
215 browser()->GetProfile()->GetExtensionService()->AddExtension( | |
216 extension.get()); | |
217 | |
218 // Makes sure that async task ExtensionPrefs::OnExtensionInstalled gets a | |
219 // chance to be procesed. | |
220 MessageLoop::current()->RunAllPending(); | |
221 | |
222 // Creates a panel with the app name that comes from the extension ID. | |
223 PanelBrowserView* browser_view = CreatePanelBrowserView( | |
224 web_app::GenerateApplicationNameFromExtensionId(extension->id())); | |
225 PanelBrowserFrameView* frame_view = browser_view->GetFrameView(); | |
226 | |
227 frame_view->EnsureCreateWrenchMenu(); | |
228 ASSERT_TRUE(frame_view->wrench_menu_.get()); | |
229 ASSERT_TRUE(frame_view->wrench_menu_contents_.get()); | |
230 | |
231 // Validates the wrench menu items. | |
232 MenuItem panel_menu[] = { | |
233 { PanelBrowserFrameView::COMMAND_NAME, false }, | |
234 { -1, false }, // Separator | |
235 { PanelBrowserFrameView::COMMAND_CONFIGURE, false }, | |
236 { PanelBrowserFrameView::COMMAND_DISABLE, false }, | |
237 { PanelBrowserFrameView::COMMAND_UNINSTALL, false }, | |
238 { -1, false }, // Separator | |
239 { PanelBrowserFrameView::COMMAND_MANAGE, true } | |
240 }; | |
241 if (!homepage_url.empty()) | |
242 panel_menu[0].enabled = true; | |
243 if (!options_page.empty()) | |
244 panel_menu[2].enabled = true; | |
245 if (location != Extension::EXTERNAL_POLICY_DOWNLOAD) { | |
246 panel_menu[3].enabled = true; | |
247 panel_menu[4].enabled = true; | |
248 } | |
249 size_t panel_menu_count = arraysize(panel_menu); | |
250 ValidateWrenchMenuItems(frame_view->wrench_menu_contents_.get(), | |
251 panel_menu_count, | |
252 panel_menu); | |
253 | |
254 browser_view->panel()->Close(); | |
255 } | |
164 }; | 256 }; |
165 | 257 |
166 // Panel is not supported for Linux view yet. | 258 // Panel is not supported for Linux view yet. |
167 #if !defined(OS_LINUX) || !defined(TOOLKIT_VIEWS) | 259 #if !defined(OS_LINUX) || !defined(TOOLKIT_VIEWS) |
168 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, CreatePanel) { | 260 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, CreatePanel) { |
169 PanelBrowserView* browser_view = CreatePanelBrowserView("PanelTest"); | 261 PanelBrowserView* browser_view = CreatePanelBrowserView("PanelTest"); |
170 PanelBrowserFrameView* frame_view = browser_view->GetFrameView(); | 262 PanelBrowserFrameView* frame_view = browser_view->GetFrameView(); |
171 | 263 |
172 // The bounds animation should not be triggered when the panel is up for the | 264 // The bounds animation should not be triggered when the panel is up for the |
173 // first time. | 265 // first time. |
174 EXPECT_FALSE(browser_view->bounds_animator_.get()); | 266 EXPECT_FALSE(browser_view->bounds_animator_.get()); |
175 | 267 |
176 // We should have icon, text, options button and close button. | 268 // We should have icon, text, wrench button and close button. |
177 EXPECT_EQ(4, frame_view->child_count()); | 269 EXPECT_EQ(4, frame_view->child_count()); |
178 EXPECT_TRUE(frame_view->Contains(frame_view->title_icon_)); | 270 EXPECT_TRUE(frame_view->Contains(frame_view->title_icon_)); |
179 EXPECT_TRUE(frame_view->Contains(frame_view->title_label_)); | 271 EXPECT_TRUE(frame_view->Contains(frame_view->title_label_)); |
180 EXPECT_TRUE(frame_view->Contains(frame_view->info_button_)); | 272 EXPECT_TRUE(frame_view->Contains(frame_view->wrench_button_)); |
181 EXPECT_TRUE(frame_view->Contains(frame_view->close_button_)); | 273 EXPECT_TRUE(frame_view->Contains(frame_view->close_button_)); |
182 | 274 |
183 // These controls should be visible. | 275 // These controls should be visible. |
184 EXPECT_TRUE(frame_view->title_icon_->IsVisible()); | 276 EXPECT_TRUE(frame_view->title_icon_->IsVisible()); |
185 EXPECT_TRUE(frame_view->title_label_->IsVisible()); | 277 EXPECT_TRUE(frame_view->title_label_->IsVisible()); |
186 EXPECT_TRUE(frame_view->close_button_->IsVisible()); | 278 EXPECT_TRUE(frame_view->close_button_->IsVisible()); |
187 | 279 |
188 // Validate their layouts. | 280 // Validate their layouts. |
189 int title_bar_height = frame_view->NonClientTopBorderHeight() - | 281 int title_bar_height = frame_view->NonClientTopBorderHeight() - |
190 frame_view->NonClientBorderThickness(); | 282 frame_view->NonClientBorderThickness(); |
191 EXPECT_GT(frame_view->title_icon_->width(), 0); | 283 EXPECT_GT(frame_view->title_icon_->width(), 0); |
192 EXPECT_GT(frame_view->title_icon_->height(), 0); | 284 EXPECT_GT(frame_view->title_icon_->height(), 0); |
193 EXPECT_LT(frame_view->title_icon_->height(), title_bar_height); | 285 EXPECT_LT(frame_view->title_icon_->height(), title_bar_height); |
194 EXPECT_GT(frame_view->title_label_->width(), 0); | 286 EXPECT_GT(frame_view->title_label_->width(), 0); |
195 EXPECT_GT(frame_view->title_label_->height(), 0); | 287 EXPECT_GT(frame_view->title_label_->height(), 0); |
196 EXPECT_LT(frame_view->title_label_->height(), title_bar_height); | 288 EXPECT_LT(frame_view->title_label_->height(), title_bar_height); |
197 EXPECT_GT(frame_view->info_button_->width(), 0); | 289 EXPECT_GT(frame_view->wrench_button_->width(), 0); |
198 EXPECT_GT(frame_view->info_button_->height(), 0); | 290 EXPECT_GT(frame_view->wrench_button_->height(), 0); |
199 EXPECT_LT(frame_view->info_button_->height(), title_bar_height); | 291 EXPECT_LT(frame_view->wrench_button_->height(), title_bar_height); |
200 EXPECT_GT(frame_view->close_button_->width(), 0); | 292 EXPECT_GT(frame_view->close_button_->width(), 0); |
201 EXPECT_GT(frame_view->close_button_->height(), 0); | 293 EXPECT_GT(frame_view->close_button_->height(), 0); |
202 EXPECT_LT(frame_view->close_button_->height(), title_bar_height); | 294 EXPECT_LT(frame_view->close_button_->height(), title_bar_height); |
203 EXPECT_LT(frame_view->title_icon_->x() + frame_view->title_icon_->width(), | 295 EXPECT_LT(frame_view->title_icon_->x() + frame_view->title_icon_->width(), |
204 frame_view->title_label_->x()); | 296 frame_view->title_label_->x()); |
205 EXPECT_LT(frame_view->title_label_->x() + frame_view->title_label_->width(), | 297 EXPECT_LT(frame_view->title_label_->x() + frame_view->title_label_->width(), |
206 frame_view->info_button_->x()); | 298 frame_view->wrench_button_->x()); |
207 EXPECT_LT( | 299 EXPECT_LT( |
208 frame_view->info_button_->x() + frame_view->info_button_->width(), | 300 frame_view->wrench_button_->x() + frame_view->wrench_button_->width(), |
209 frame_view->close_button_->x()); | 301 frame_view->close_button_->x()); |
210 | 302 |
211 // Validate that the controls should be updated when the activation state is | 303 // Validate that the controls should be updated when the activation state is |
212 // changed. | 304 // changed. |
213 frame_view->UpdateControlStyles(PanelBrowserFrameView::PAINT_AS_ACTIVE); | 305 frame_view->UpdateControlStyles(PanelBrowserFrameView::PAINT_AS_ACTIVE); |
214 gfx::Font title_label_font1 = frame_view->title_label_->font(); | 306 gfx::Font title_label_font1 = frame_view->title_label_->font(); |
215 frame_view->UpdateControlStyles(PanelBrowserFrameView::PAINT_AS_INACTIVE); | 307 frame_view->UpdateControlStyles(PanelBrowserFrameView::PAINT_AS_INACTIVE); |
216 gfx::Font title_label_font2 = frame_view->title_label_->font(); | 308 gfx::Font title_label_font2 = frame_view->title_label_->font(); |
217 EXPECT_NE(title_label_font1.GetStyle(), title_label_font2.GetStyle()); | 309 EXPECT_NE(title_label_font1.GetStyle(), title_label_font2.GetStyle()); |
218 } | 310 } |
219 | 311 |
220 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, ShowOrHideInfoButton) { | 312 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, ShowOrHideWrenchButton) { |
221 PanelBrowserView* browser_view = CreatePanelBrowserView("PanelTest"); | 313 PanelBrowserView* browser_view = CreatePanelBrowserView("PanelTest"); |
222 PanelBrowserFrameView* frame_view = browser_view->GetFrameView(); | 314 PanelBrowserFrameView* frame_view = browser_view->GetFrameView(); |
223 | 315 |
224 // Create and hook up the MockMouseWatcher so that we can simulate if the | 316 // Create and hook up the MockMouseWatcher so that we can simulate if the |
225 // mouse is over the panel. | 317 // mouse is over the panel. |
226 MockMouseWatcher* mouse_watcher = new MockMouseWatcher(frame_view); | 318 MockMouseWatcher* mouse_watcher = new MockMouseWatcher(frame_view); |
227 frame_view->set_mouse_watcher(mouse_watcher); | 319 frame_view->set_mouse_watcher(mouse_watcher); |
228 | 320 |
229 // When the panel is created, it is active. Since we cannot programatically | 321 // When the panel is created, it is active. Since we cannot programatically |
230 // bring the panel back to active state once it is deactivated, we have to | 322 // bring the panel back to active state once it is deactivated, we have to |
231 // test the cases that the panel is active first. | 323 // test the cases that the panel is active first. |
232 EXPECT_TRUE(browser_view->panel()->IsActive()); | 324 EXPECT_TRUE(browser_view->panel()->IsActive()); |
233 | 325 |
234 // When the panel is active, the info button should always be visible. | 326 // When the panel is active, the wrench button should always be visible. |
235 mouse_watcher->MoveMouse(true); | 327 mouse_watcher->MoveMouse(true); |
236 EXPECT_TRUE(frame_view->info_button_->IsVisible()); | 328 EXPECT_TRUE(frame_view->wrench_button_->IsVisible()); |
237 mouse_watcher->MoveMouse(false); | 329 mouse_watcher->MoveMouse(false); |
238 EXPECT_TRUE(frame_view->info_button_->IsVisible()); | 330 EXPECT_TRUE(frame_view->wrench_button_->IsVisible()); |
239 | 331 |
240 // When the panel is inactive, the info button is active per the mouse over | 332 // When the panel is inactive, the options button is active per the mouse over |
241 // the panel or not. | 333 // the panel or not. |
242 browser_view->panel()->Deactivate(); | 334 browser_view->panel()->Deactivate(); |
243 EXPECT_FALSE(browser_view->panel()->IsActive()); | 335 EXPECT_FALSE(browser_view->panel()->IsActive()); |
244 | 336 |
245 mouse_watcher->MoveMouse(true); | 337 mouse_watcher->MoveMouse(true); |
246 EXPECT_TRUE(frame_view->info_button_->IsVisible()); | 338 EXPECT_TRUE(frame_view->wrench_button_->IsVisible()); |
247 mouse_watcher->MoveMouse(false); | 339 mouse_watcher->MoveMouse(false); |
248 EXPECT_FALSE(frame_view->info_button_->IsVisible()); | 340 EXPECT_FALSE(frame_view->wrench_button_->IsVisible()); |
249 } | 341 } |
250 | 342 |
251 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, TitleBarMouseEvent) { | 343 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, TitleBarMouseEvent) { |
252 // TODO(jianli): Move the test to platform-independent PanelManager unittest. | 344 // TODO(jianli): Move the test to platform-independent PanelManager unittest. |
253 | 345 |
254 // Creates the 1st panel. | 346 // Creates the 1st panel. |
255 PanelBrowserView* browser_view1 = CreatePanelBrowserView("PanelTest1"); | 347 PanelBrowserView* browser_view1 = CreatePanelBrowserView("PanelTest1"); |
256 | 348 |
257 // The delta is from the pressed location which is the left-top corner of the | 349 // The delta is from the pressed location which is the left-top corner of the |
258 // panel to drag. | 350 // panel to drag. |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
416 false); | 508 false); |
417 } | 509 } |
418 | 510 |
419 // Closes all panels. | 511 // Closes all panels. |
420 for (size_t i = 0; i < browser_view_count; ++i) { | 512 for (size_t i = 0; i < browser_view_count; ++i) { |
421 browser_views[i]->panel()->Close(); | 513 browser_views[i]->panel()->Close(); |
422 EXPECT_FALSE(browser_views[i]->panel()); | 514 EXPECT_FALSE(browser_views[i]->panel()); |
423 } | 515 } |
424 } | 516 } |
425 | 517 |
426 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, AboutPanelBubble) { | |
427 ExtensionService* extension_service = | |
428 browser()->GetProfile()->GetExtensionService(); | |
429 | |
430 // Create a testing extension. | |
431 #if defined(OS_WIN) | |
432 FilePath path(FILE_PATH_LITERAL("c:\\foo")); | |
433 #else | |
434 FilePath path(FILE_PATH_LITERAL("/foo")); | |
435 #endif | |
436 DictionaryValue input_value; | |
437 input_value.SetString(extension_manifest_keys::kVersion, "1.0.0.0"); | |
438 input_value.SetString(extension_manifest_keys::kName, "Sample Extension"); | |
439 input_value.SetString(extension_manifest_keys::kDescription, | |
440 "Sample Description"); | |
441 scoped_refptr<Extension> extension(Extension::Create(path, Extension::INVALID, | |
442 input_value, Extension::STRICT_ERROR_CHECKS, NULL)); | |
443 ASSERT_TRUE(extension.get()); | |
444 extension_service->AddExtension(extension.get()); | |
445 // Make sure that async task ExtensionPrefs::OnExtensionInstalled gets a | |
446 // chance to be procesed. | |
447 MessageLoop::current()->RunAllPending(); | |
448 | |
449 extension_service->extension_prefs()->OnExtensionInstalled( | |
450 extension, Extension::ENABLED); | |
451 | |
452 // Create a panel with the app name that comes from the extension ID. | |
453 PanelBrowserView* browser_view = CreatePanelBrowserView( | |
454 web_app::GenerateApplicationNameFromExtensionId(extension->id())); | |
455 | |
456 AboutPanelBubble* bubble = AboutPanelBubble::Show( | |
457 browser_view->GetWidget(), | |
458 gfx::Rect(), | |
459 BubbleBorder::BOTTOM_RIGHT, | |
460 SkBitmap(), | |
461 browser_view->browser()); | |
462 AboutPanelBubble::AboutPanelBubbleView* contents = | |
463 static_cast<AboutPanelBubble::AboutPanelBubbleView*>(bubble->contents()); | |
464 | |
465 // We should have the expected controls. | |
466 EXPECT_EQ(6, contents->child_count()); | |
467 EXPECT_TRUE(contents->Contains(contents->icon_)); | |
468 EXPECT_TRUE(contents->Contains(contents->title_)); | |
469 EXPECT_TRUE(contents->Contains(contents->install_date_)); | |
470 EXPECT_TRUE(contents->Contains(contents->description_)); | |
471 EXPECT_TRUE(contents->Contains(contents->uninstall_link_)); | |
472 EXPECT_TRUE(contents->Contains(contents->report_abuse_link_)); | |
473 | |
474 // These controls should be visible. | |
475 EXPECT_TRUE(contents->icon_->IsVisible()); | |
476 EXPECT_TRUE(contents->title_->IsVisible()); | |
477 EXPECT_TRUE(contents->install_date_->IsVisible()); | |
478 EXPECT_TRUE(contents->description_->IsVisible()); | |
479 EXPECT_TRUE(contents->uninstall_link_->IsVisible()); | |
480 EXPECT_TRUE(contents->report_abuse_link_->IsVisible()); | |
481 | |
482 // Validate their layouts. | |
483 EXPECT_GT(contents->title_->x(), contents->icon_->x()); | |
484 EXPECT_GT(contents->title_->width(), 0); | |
485 EXPECT_GT(contents->title_->height(), 0); | |
486 EXPECT_EQ(contents->install_date_->x(), contents->title_->x()); | |
487 EXPECT_GT(contents->install_date_->y(), contents->title_->y()); | |
488 EXPECT_GT(contents->install_date_->width(), 0); | |
489 EXPECT_GT(contents->install_date_->height(), 0); | |
490 EXPECT_EQ(contents->description_->x(), contents->install_date_->x()); | |
491 EXPECT_GT(contents->description_->y(), contents->install_date_->y()); | |
492 EXPECT_GT(contents->description_->width(), 0); | |
493 EXPECT_GT(contents->description_->height(), 0); | |
494 EXPECT_EQ(contents->uninstall_link_->x(), contents->description_->x()); | |
495 EXPECT_GT(contents->uninstall_link_->y(), contents->description_->y()); | |
496 EXPECT_GT(contents->uninstall_link_->width(), 0); | |
497 EXPECT_GT(contents->uninstall_link_->height(), 0); | |
498 EXPECT_GT(contents->report_abuse_link_->x(), contents->uninstall_link_->x()); | |
499 EXPECT_EQ(contents->report_abuse_link_->y(), contents->uninstall_link_->y()); | |
500 EXPECT_GT(contents->report_abuse_link_->width(), 0); | |
501 EXPECT_GT(contents->report_abuse_link_->height(), 0); | |
502 | |
503 // Validates the texts. | |
504 base::Time install_time = | |
505 extension_service->extension_prefs()->GetInstallTime(extension->id()); | |
506 string16 time_text = l10n_util::GetStringFUTF16( | |
507 IDS_ABOUT_PANEL_BUBBLE_EXTENSION_INSTALL_DATE, | |
508 base::TimeFormatFriendlyDate( | |
509 extension_service->extension_prefs()->GetInstallTime( | |
510 extension->id()))); | |
511 EXPECT_STREQ(UTF16ToUTF8(time_text).c_str(), | |
512 WideToUTF8(contents->install_date_->GetText()).c_str()); | |
513 EXPECT_STREQ(extension->description().c_str(), | |
514 UTF16ToUTF8(contents->description_->text()).c_str()); | |
515 } | |
516 | |
517 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, SetBoundsAnimation) { | 518 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, SetBoundsAnimation) { |
518 PanelBrowserView* browser_view = CreatePanelBrowserView("PanelTest"); | 519 PanelBrowserView* browser_view = CreatePanelBrowserView("PanelTest"); |
519 | 520 |
520 // Validate that animation should be triggered when SetBounds is called. | 521 // Validate that animation should be triggered when SetBounds is called. |
521 gfx::Rect target_bounds(browser_view->GetBounds()); | 522 gfx::Rect target_bounds(browser_view->GetBounds()); |
522 target_bounds.Offset(20, -30); | 523 target_bounds.Offset(20, -30); |
523 target_bounds.set_width(target_bounds.width() + 100); | 524 target_bounds.set_width(target_bounds.width() + 100); |
524 target_bounds.set_height(target_bounds.height() + 50); | 525 target_bounds.set_height(target_bounds.height() + 50); |
525 browser_view->SetBounds(target_bounds); | 526 browser_view->SetBounds(target_bounds); |
526 ASSERT_TRUE(browser_view->bounds_animator_.get()); | 527 ASSERT_TRUE(browser_view->bounds_animator_.get()); |
(...skipping 16 matching lines...) Expand all Loading... | |
543 views::MouseEvent dragged(ui::ET_MOUSE_DRAGGED, | 544 views::MouseEvent dragged(ui::ET_MOUSE_DRAGGED, |
544 target_bounds.x() + 5, | 545 target_bounds.x() + 5, |
545 target_bounds.y() + 5, | 546 target_bounds.y() + 5, |
546 ui::EF_LEFT_BUTTON_DOWN); | 547 ui::EF_LEFT_BUTTON_DOWN); |
547 browser_view->OnTitleBarMouseDragged(dragged); | 548 browser_view->OnTitleBarMouseDragged(dragged); |
548 EXPECT_FALSE(browser_view->bounds_animator_->is_animating()); | 549 EXPECT_FALSE(browser_view->bounds_animator_->is_animating()); |
549 browser_view->OnTitleBarMouseCaptureLost(); | 550 browser_view->OnTitleBarMouseCaptureLost(); |
550 | 551 |
551 browser_view->panel()->Close(); | 552 browser_view->panel()->Close(); |
552 } | 553 } |
554 | |
555 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, CreateWrenchMenu) { | |
556 TestCreateWrenchMenuForExtension( | |
557 FILE_PATH_LITERAL("extension1"), Extension::EXTERNAL_POLICY_DOWNLOAD, | |
558 "", ""); | |
559 TestCreateWrenchMenuForExtension( | |
560 FILE_PATH_LITERAL("extension2"), Extension::INVALID, | |
561 "http://home", "options.html"); | |
562 } | |
553 #endif | 563 #endif |
OLD | NEW |