| 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 ValidateSettingsMenuItems(ui::SimpleMenuModel* settings_menu_contents, |
| 172 size_t num_expected_menu_items, |
| 173 const MenuItem* expected_menu_items) { |
| 174 ASSERT_TRUE(settings_menu_contents); |
| 175 EXPECT_EQ(static_cast<int>(num_expected_menu_items), |
| 176 settings_menu_contents->GetItemCount()); |
| 177 for (size_t i = 0; i < num_expected_menu_items; ++i) { |
| 178 if (expected_menu_items[i].id == -1) { |
| 179 EXPECT_EQ(ui::MenuModel::TYPE_SEPARATOR, |
| 180 settings_menu_contents->GetTypeAt(i)); |
| 181 } else { |
| 182 EXPECT_EQ(expected_menu_items[i].id, |
| 183 settings_menu_contents->GetCommandIdAt(i)); |
| 184 EXPECT_EQ(expected_menu_items[i].enabled, |
| 185 settings_menu_contents->IsEnabledAt(i)); |
| 186 } |
| 187 } |
| 188 } |
| 189 |
| 190 void TestCreateSettingsMenuForExtension(const FilePath::StringType& path, |
| 191 Extension::Location location, |
| 192 const std::string& homepage_url, |
| 193 const std::string& options_page) { |
| 194 // Creates a testing extension. |
| 195 #if defined(OS_WIN) |
| 196 FilePath full_path(FILE_PATH_LITERAL("c:\\")); |
| 197 #else |
| 198 FilePath full_path(FILE_PATH_LITERAL("/")); |
| 199 #endif |
| 200 full_path.Append(path); |
| 201 DictionaryValue input_value; |
| 202 input_value.SetString(extension_manifest_keys::kVersion, "1.0.0.0"); |
| 203 input_value.SetString(extension_manifest_keys::kName, "Sample Extension"); |
| 204 if (!homepage_url.empty()) { |
| 205 input_value.SetString(extension_manifest_keys::kHomepageURL, |
| 206 homepage_url); |
| 207 } |
| 208 if (!options_page.empty()) { |
| 209 input_value.SetString(extension_manifest_keys::kOptionsPage, |
| 210 options_page); |
| 211 } |
| 212 std::string error; |
| 213 scoped_refptr<Extension> extension = Extension::Create( |
| 214 full_path, location, input_value, Extension::STRICT_ERROR_CHECKS, |
| 215 &error); |
| 216 ASSERT_TRUE(extension.get()); |
| 217 EXPECT_STREQ("", error.c_str()); |
| 218 browser()->GetProfile()->GetExtensionService()->AddExtension( |
| 219 extension.get()); |
| 220 |
| 221 // Makes sure that async task ExtensionPrefs::OnExtensionInstalled gets a |
| 222 // chance to be procesed. |
| 223 MessageLoop::current()->RunAllPending(); |
| 224 |
| 225 // Creates a panel with the app name that comes from the extension ID. |
| 226 PanelBrowserView* browser_view = CreatePanelBrowserView( |
| 227 web_app::GenerateApplicationNameFromExtensionId(extension->id())); |
| 228 PanelBrowserFrameView* frame_view = browser_view->GetFrameView(); |
| 229 |
| 230 frame_view->EnsureCreateSettingsMenu(); |
| 231 ASSERT_TRUE(frame_view->settings_menu_.get()); |
| 232 ASSERT_TRUE(frame_view->settings_menu_contents_.get()); |
| 233 |
| 234 // Validates the settings menu items. |
| 235 MenuItem expected_panel_menu_items[] = { |
| 236 { PanelBrowserFrameView::COMMAND_NAME, false }, |
| 237 { -1, false }, // Separator |
| 238 { PanelBrowserFrameView::COMMAND_CONFIGURE, false }, |
| 239 { PanelBrowserFrameView::COMMAND_DISABLE, false }, |
| 240 { PanelBrowserFrameView::COMMAND_UNINSTALL, false }, |
| 241 { -1, false }, // Separator |
| 242 { PanelBrowserFrameView::COMMAND_MANAGE, true } |
| 243 }; |
| 244 if (!homepage_url.empty()) |
| 245 expected_panel_menu_items[0].enabled = true; |
| 246 if (!options_page.empty()) |
| 247 expected_panel_menu_items[2].enabled = true; |
| 248 if (location != Extension::EXTERNAL_POLICY_DOWNLOAD) { |
| 249 expected_panel_menu_items[3].enabled = true; |
| 250 expected_panel_menu_items[4].enabled = true; |
| 251 } |
| 252 ValidateSettingsMenuItems(frame_view->settings_menu_contents_.get(), |
| 253 arraysize(expected_panel_menu_items), |
| 254 expected_panel_menu_items); |
| 255 |
| 256 browser_view->panel()->Close(); |
| 257 } |
| 164 }; | 258 }; |
| 165 | 259 |
| 166 // Panel is not supported for Linux view yet. | 260 // Panel is not supported for Linux view yet. |
| 167 #if !defined(OS_LINUX) || !defined(TOOLKIT_VIEWS) | 261 #if !defined(OS_LINUX) || !defined(TOOLKIT_VIEWS) |
| 168 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, CreatePanel) { | 262 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, CreatePanel) { |
| 169 PanelBrowserView* browser_view = CreatePanelBrowserView("PanelTest"); | 263 PanelBrowserView* browser_view = CreatePanelBrowserView("PanelTest"); |
| 170 PanelBrowserFrameView* frame_view = browser_view->GetFrameView(); | 264 PanelBrowserFrameView* frame_view = browser_view->GetFrameView(); |
| 171 | 265 |
| 172 // The bounds animation should not be triggered when the panel is up for the | 266 // The bounds animation should not be triggered when the panel is up for the |
| 173 // first time. | 267 // first time. |
| 174 EXPECT_FALSE(browser_view->bounds_animator_.get()); | 268 EXPECT_FALSE(browser_view->bounds_animator_.get()); |
| 175 | 269 |
| 176 // We should have icon, text, options button and close button. | 270 // We should have icon, text, settings button and close button. |
| 177 EXPECT_EQ(4, frame_view->child_count()); | 271 EXPECT_EQ(4, frame_view->child_count()); |
| 178 EXPECT_TRUE(frame_view->Contains(frame_view->title_icon_)); | 272 EXPECT_TRUE(frame_view->Contains(frame_view->title_icon_)); |
| 179 EXPECT_TRUE(frame_view->Contains(frame_view->title_label_)); | 273 EXPECT_TRUE(frame_view->Contains(frame_view->title_label_)); |
| 180 EXPECT_TRUE(frame_view->Contains(frame_view->info_button_)); | 274 EXPECT_TRUE(frame_view->Contains(frame_view->settings_button_)); |
| 181 EXPECT_TRUE(frame_view->Contains(frame_view->close_button_)); | 275 EXPECT_TRUE(frame_view->Contains(frame_view->close_button_)); |
| 182 | 276 |
| 183 // These controls should be visible. | 277 // These controls should be visible. |
| 184 EXPECT_TRUE(frame_view->title_icon_->IsVisible()); | 278 EXPECT_TRUE(frame_view->title_icon_->IsVisible()); |
| 185 EXPECT_TRUE(frame_view->title_label_->IsVisible()); | 279 EXPECT_TRUE(frame_view->title_label_->IsVisible()); |
| 186 EXPECT_TRUE(frame_view->close_button_->IsVisible()); | 280 EXPECT_TRUE(frame_view->close_button_->IsVisible()); |
| 187 | 281 |
| 188 // Validate their layouts. | 282 // Validate their layouts. |
| 189 int title_bar_height = frame_view->NonClientTopBorderHeight() - | 283 int title_bar_height = frame_view->NonClientTopBorderHeight() - |
| 190 frame_view->NonClientBorderThickness(); | 284 frame_view->NonClientBorderThickness(); |
| 191 EXPECT_GT(frame_view->title_icon_->width(), 0); | 285 EXPECT_GT(frame_view->title_icon_->width(), 0); |
| 192 EXPECT_GT(frame_view->title_icon_->height(), 0); | 286 EXPECT_GT(frame_view->title_icon_->height(), 0); |
| 193 EXPECT_LT(frame_view->title_icon_->height(), title_bar_height); | 287 EXPECT_LT(frame_view->title_icon_->height(), title_bar_height); |
| 194 EXPECT_GT(frame_view->title_label_->width(), 0); | 288 EXPECT_GT(frame_view->title_label_->width(), 0); |
| 195 EXPECT_GT(frame_view->title_label_->height(), 0); | 289 EXPECT_GT(frame_view->title_label_->height(), 0); |
| 196 EXPECT_LT(frame_view->title_label_->height(), title_bar_height); | 290 EXPECT_LT(frame_view->title_label_->height(), title_bar_height); |
| 197 EXPECT_GT(frame_view->info_button_->width(), 0); | 291 EXPECT_GT(frame_view->settings_button_->width(), 0); |
| 198 EXPECT_GT(frame_view->info_button_->height(), 0); | 292 EXPECT_GT(frame_view->settings_button_->height(), 0); |
| 199 EXPECT_LT(frame_view->info_button_->height(), title_bar_height); | 293 EXPECT_LT(frame_view->settings_button_->height(), title_bar_height); |
| 200 EXPECT_GT(frame_view->close_button_->width(), 0); | 294 EXPECT_GT(frame_view->close_button_->width(), 0); |
| 201 EXPECT_GT(frame_view->close_button_->height(), 0); | 295 EXPECT_GT(frame_view->close_button_->height(), 0); |
| 202 EXPECT_LT(frame_view->close_button_->height(), title_bar_height); | 296 EXPECT_LT(frame_view->close_button_->height(), title_bar_height); |
| 203 EXPECT_LT(frame_view->title_icon_->x() + frame_view->title_icon_->width(), | 297 EXPECT_LT(frame_view->title_icon_->x() + frame_view->title_icon_->width(), |
| 204 frame_view->title_label_->x()); | 298 frame_view->title_label_->x()); |
| 205 EXPECT_LT(frame_view->title_label_->x() + frame_view->title_label_->width(), | 299 EXPECT_LT(frame_view->title_label_->x() + frame_view->title_label_->width(), |
| 206 frame_view->info_button_->x()); | 300 frame_view->settings_button_->x()); |
| 207 EXPECT_LT( | 301 EXPECT_LT( |
| 208 frame_view->info_button_->x() + frame_view->info_button_->width(), | 302 frame_view->settings_button_->x() + frame_view->settings_button_->width(), |
| 209 frame_view->close_button_->x()); | 303 frame_view->close_button_->x()); |
| 210 | 304 |
| 211 // Validate that the controls should be updated when the activation state is | 305 // Validate that the controls should be updated when the activation state is |
| 212 // changed. | 306 // changed. |
| 213 frame_view->UpdateControlStyles(PanelBrowserFrameView::PAINT_AS_ACTIVE); | 307 frame_view->UpdateControlStyles(PanelBrowserFrameView::PAINT_AS_ACTIVE); |
| 214 gfx::Font title_label_font1 = frame_view->title_label_->font(); | 308 gfx::Font title_label_font1 = frame_view->title_label_->font(); |
| 215 frame_view->UpdateControlStyles(PanelBrowserFrameView::PAINT_AS_INACTIVE); | 309 frame_view->UpdateControlStyles(PanelBrowserFrameView::PAINT_AS_INACTIVE); |
| 216 gfx::Font title_label_font2 = frame_view->title_label_->font(); | 310 gfx::Font title_label_font2 = frame_view->title_label_->font(); |
| 217 EXPECT_NE(title_label_font1.GetStyle(), title_label_font2.GetStyle()); | 311 EXPECT_NE(title_label_font1.GetStyle(), title_label_font2.GetStyle()); |
| 218 } | 312 } |
| 219 | 313 |
| 220 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, ShowOrHideInfoButton) { | 314 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, ShowOrHideSettingsButton) { |
| 221 PanelBrowserView* browser_view = CreatePanelBrowserView("PanelTest"); | 315 PanelBrowserView* browser_view = CreatePanelBrowserView("PanelTest"); |
| 222 PanelBrowserFrameView* frame_view = browser_view->GetFrameView(); | 316 PanelBrowserFrameView* frame_view = browser_view->GetFrameView(); |
| 223 | 317 |
| 224 // Create and hook up the MockMouseWatcher so that we can simulate if the | 318 // Create and hook up the MockMouseWatcher so that we can simulate if the |
| 225 // mouse is over the panel. | 319 // mouse is over the panel. |
| 226 MockMouseWatcher* mouse_watcher = new MockMouseWatcher(frame_view); | 320 MockMouseWatcher* mouse_watcher = new MockMouseWatcher(frame_view); |
| 227 frame_view->set_mouse_watcher(mouse_watcher); | 321 frame_view->set_mouse_watcher(mouse_watcher); |
| 228 | 322 |
| 229 // When the panel is created, it is active. Since we cannot programatically | 323 // 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 | 324 // bring the panel back to active state once it is deactivated, we have to |
| 231 // test the cases that the panel is active first. | 325 // test the cases that the panel is active first. |
| 232 EXPECT_TRUE(browser_view->panel()->IsActive()); | 326 EXPECT_TRUE(browser_view->panel()->IsActive()); |
| 233 | 327 |
| 234 // When the panel is active, the info button should always be visible. | 328 // When the panel is active, the settings button should always be visible. |
| 235 mouse_watcher->MoveMouse(true); | 329 mouse_watcher->MoveMouse(true); |
| 236 EXPECT_TRUE(frame_view->info_button_->IsVisible()); | 330 EXPECT_TRUE(frame_view->settings_button_->IsVisible()); |
| 237 mouse_watcher->MoveMouse(false); | 331 mouse_watcher->MoveMouse(false); |
| 238 EXPECT_TRUE(frame_view->info_button_->IsVisible()); | 332 EXPECT_TRUE(frame_view->settings_button_->IsVisible()); |
| 239 | 333 |
| 240 // When the panel is inactive, the info button is active per the mouse over | 334 // When the panel is inactive, the options button is active per the mouse over |
| 241 // the panel or not. | 335 // the panel or not. |
| 242 browser_view->panel()->Deactivate(); | 336 browser_view->panel()->Deactivate(); |
| 243 EXPECT_FALSE(browser_view->panel()->IsActive()); | 337 EXPECT_FALSE(browser_view->panel()->IsActive()); |
| 244 | 338 |
| 245 mouse_watcher->MoveMouse(true); | 339 mouse_watcher->MoveMouse(true); |
| 246 EXPECT_TRUE(frame_view->info_button_->IsVisible()); | 340 EXPECT_TRUE(frame_view->settings_button_->IsVisible()); |
| 247 mouse_watcher->MoveMouse(false); | 341 mouse_watcher->MoveMouse(false); |
| 248 EXPECT_FALSE(frame_view->info_button_->IsVisible()); | 342 EXPECT_FALSE(frame_view->settings_button_->IsVisible()); |
| 249 } | 343 } |
| 250 | 344 |
| 251 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, TitleBarMouseEvent) { | 345 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, TitleBarMouseEvent) { |
| 252 // TODO(jianli): Move the test to platform-independent PanelManager unittest. | 346 // TODO(jianli): Move the test to platform-independent PanelManager unittest. |
| 253 | 347 |
| 254 // Creates the 1st panel. | 348 // Creates the 1st panel. |
| 255 PanelBrowserView* browser_view1 = CreatePanelBrowserView("PanelTest1"); | 349 PanelBrowserView* browser_view1 = CreatePanelBrowserView("PanelTest1"); |
| 256 | 350 |
| 257 // The delta is from the pressed location which is the left-top corner of the | 351 // The delta is from the pressed location which is the left-top corner of the |
| 258 // panel to drag. | 352 // panel to drag. |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 false); | 510 false); |
| 417 } | 511 } |
| 418 | 512 |
| 419 // Closes all panels. | 513 // Closes all panels. |
| 420 for (size_t i = 0; i < browser_view_count; ++i) { | 514 for (size_t i = 0; i < browser_view_count; ++i) { |
| 421 browser_views[i]->panel()->Close(); | 515 browser_views[i]->panel()->Close(); |
| 422 EXPECT_FALSE(browser_views[i]->panel()); | 516 EXPECT_FALSE(browser_views[i]->panel()); |
| 423 } | 517 } |
| 424 } | 518 } |
| 425 | 519 |
| 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) { | 520 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, SetBoundsAnimation) { |
| 518 PanelBrowserView* browser_view = CreatePanelBrowserView("PanelTest"); | 521 PanelBrowserView* browser_view = CreatePanelBrowserView("PanelTest"); |
| 519 | 522 |
| 520 // Validate that animation should be triggered when SetBounds is called. | 523 // Validate that animation should be triggered when SetBounds is called. |
| 521 gfx::Rect target_bounds(browser_view->GetBounds()); | 524 gfx::Rect target_bounds(browser_view->GetBounds()); |
| 522 target_bounds.Offset(20, -30); | 525 target_bounds.Offset(20, -30); |
| 523 target_bounds.set_width(target_bounds.width() + 100); | 526 target_bounds.set_width(target_bounds.width() + 100); |
| 524 target_bounds.set_height(target_bounds.height() + 50); | 527 target_bounds.set_height(target_bounds.height() + 50); |
| 525 browser_view->SetBounds(target_bounds); | 528 browser_view->SetBounds(target_bounds); |
| 526 ASSERT_TRUE(browser_view->bounds_animator_.get()); | 529 ASSERT_TRUE(browser_view->bounds_animator_.get()); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 543 views::MouseEvent dragged(ui::ET_MOUSE_DRAGGED, | 546 views::MouseEvent dragged(ui::ET_MOUSE_DRAGGED, |
| 544 target_bounds.x() + 5, | 547 target_bounds.x() + 5, |
| 545 target_bounds.y() + 5, | 548 target_bounds.y() + 5, |
| 546 ui::EF_LEFT_BUTTON_DOWN); | 549 ui::EF_LEFT_BUTTON_DOWN); |
| 547 browser_view->OnTitleBarMouseDragged(dragged); | 550 browser_view->OnTitleBarMouseDragged(dragged); |
| 548 EXPECT_FALSE(browser_view->bounds_animator_->is_animating()); | 551 EXPECT_FALSE(browser_view->bounds_animator_->is_animating()); |
| 549 browser_view->OnTitleBarMouseCaptureLost(); | 552 browser_view->OnTitleBarMouseCaptureLost(); |
| 550 | 553 |
| 551 browser_view->panel()->Close(); | 554 browser_view->panel()->Close(); |
| 552 } | 555 } |
| 556 |
| 557 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, CreateSettingsMenu) { |
| 558 TestCreateSettingsMenuForExtension( |
| 559 FILE_PATH_LITERAL("extension1"), Extension::EXTERNAL_POLICY_DOWNLOAD, |
| 560 "", ""); |
| 561 TestCreateSettingsMenuForExtension( |
| 562 FILE_PATH_LITERAL("extension2"), Extension::INVALID, |
| 563 "http://home", "options.html"); |
| 564 } |
| 553 #endif | 565 #endif |
| OLD | NEW |