| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #import "chrome/browser/ui/cocoa/extensions/browser_action_button.h" | 5 #import "chrome/browser/ui/cocoa/extensions/browser_action_button.h" |
| 6 | 6 |
| 7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/callback_helpers.h" | 13 #include "base/callback_helpers.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/ptr_util.h" |
| 15 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
| 16 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 17 #include "base/threading/thread_task_runner_handle.h" | 18 #include "base/threading/thread_task_runner_handle.h" |
| 18 #include "chrome/browser/extensions/extension_action_test_util.h" | 19 #include "chrome/browser/extensions/extension_action_test_util.h" |
| 19 #include "chrome/browser/extensions/extension_browsertest.h" | 20 #include "chrome/browser/extensions/extension_browsertest.h" |
| 20 #include "chrome/browser/extensions/extension_service.h" | 21 #include "chrome/browser/extensions/extension_service.h" |
| 21 #include "chrome/browser/ui/browser_window.h" | 22 #include "chrome/browser/ui/browser_window.h" |
| 22 #import "chrome/browser/ui/cocoa/app_menu/app_menu_controller.h" | 23 #import "chrome/browser/ui/cocoa/app_menu/app_menu_controller.h" |
| 23 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 24 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 24 #import "chrome/browser/ui/cocoa/extensions/browser_actions_container_view.h" | 25 #import "chrome/browser/ui/cocoa/extensions/browser_actions_container_view.h" |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 }; | 478 }; |
| 478 | 479 |
| 479 // Test the layout with gradually more extensions hidden. | 480 // Test the layout with gradually more extensions hidden. |
| 480 for (int i = 1; i <= kNumExtensions; ++i) | 481 for (int i = 1; i <= kNumExtensions; ++i) |
| 481 resizeAndActivateAppMenu(i, base::StringPrintf("Normal: %d", i)); | 482 resizeAndActivateAppMenu(i, base::StringPrintf("Normal: %d", i)); |
| 482 | 483 |
| 483 // Adding a global error adjusts the app menu size, and has been known to mess | 484 // Adding a global error adjusts the app menu size, and has been known to mess |
| 484 // up the overflow container's bounds (crbug.com/511326). | 485 // up the overflow container's bounds (crbug.com/511326). |
| 485 GlobalErrorService* error_service = | 486 GlobalErrorService* error_service = |
| 486 GlobalErrorServiceFactory::GetForProfile(profile()); | 487 GlobalErrorServiceFactory::GetForProfile(profile()); |
| 487 error_service->AddGlobalError(new MenuError()); | 488 error_service->AddGlobalError(base::MakeUnique<MenuError>()); |
| 488 | 489 |
| 489 // It's probably excessive to test every level of the overflow here. Test | 490 // It's probably excessive to test every level of the overflow here. Test |
| 490 // having all actions overflowed, some actions overflowed, and one action | 491 // having all actions overflowed, some actions overflowed, and one action |
| 491 // overflowed. | 492 // overflowed. |
| 492 resizeAndActivateAppMenu(kNumExtensions, "GlobalError Full"); | 493 resizeAndActivateAppMenu(kNumExtensions, "GlobalError Full"); |
| 493 resizeAndActivateAppMenu(kNumExtensions / 2, "GlobalError Half"); | 494 resizeAndActivateAppMenu(kNumExtensions / 2, "GlobalError Half"); |
| 494 resizeAndActivateAppMenu(1, "GlobalError One"); | 495 resizeAndActivateAppMenu(1, "GlobalError One"); |
| 495 } | 496 } |
| 496 | 497 |
| 497 void AddExtensionWithMenuOpen(ToolbarController* toolbarController, | 498 void AddExtensionWithMenuOpen(ToolbarController* toolbarController, |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 openAndCloseAppMenu(appMenuController()); | 643 openAndCloseAppMenu(appMenuController()); |
| 643 | 644 |
| 644 // Move the extension back to the main bar, so an overflow bar is no longer | 645 // Move the extension back to the main bar, so an overflow bar is no longer |
| 645 // needed. Then open and close the app menu a couple times. | 646 // needed. Then open and close the app menu a couple times. |
| 646 // This tests that the menu properly cleans up after itself when an overflow | 647 // This tests that the menu properly cleans up after itself when an overflow |
| 647 // was present, and is no longer (fix for crbug.com/603241). | 648 // was present, and is no longer (fix for crbug.com/603241). |
| 648 model()->SetVisibleIconCount(1); | 649 model()->SetVisibleIconCount(1); |
| 649 openAndCloseAppMenu(appMenuController()); | 650 openAndCloseAppMenu(appMenuController()); |
| 650 openAndCloseAppMenu(appMenuController()); | 651 openAndCloseAppMenu(appMenuController()); |
| 651 } | 652 } |
| OLD | NEW |