| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "browser_action_test_util.h" | 5 #include "browser_action_test_util.h" |
| 6 | 6 |
| 7 #include "base/mac/foundation_util.h" |
| 7 #include "base/sys_string_conversions.h" | 8 #include "base/sys_string_conversions.h" |
| 8 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
| 9 #import "chrome/browser/ui/cocoa/browser_window_cocoa.h" | 10 #import "chrome/browser/ui/cocoa/browser_window_cocoa.h" |
| 10 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 11 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 11 #import "chrome/browser/ui/cocoa/extensions/browser_actions_controller.h" | 12 #import "chrome/browser/ui/cocoa/extensions/browser_actions_controller.h" |
| 12 #import "chrome/browser/ui/cocoa/extensions/extension_popup_controller.h" | 13 #import "chrome/browser/ui/cocoa/extensions/extension_popup_controller.h" |
| 13 #import "chrome/browser/ui/cocoa/info_bubble_window.h" | 14 #import "chrome/browser/ui/cocoa/info_bubble_window.h" |
| 14 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" | 15 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" |
| 15 #include "ui/gfx/rect.h" | 16 #include "ui/gfx/rect.h" |
| 16 #include "ui/gfx/size.h" | 17 #include "ui/gfx/size.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 32 } // namespace | 33 } // namespace |
| 33 | 34 |
| 34 int BrowserActionTestUtil::NumberOfBrowserActions() { | 35 int BrowserActionTestUtil::NumberOfBrowserActions() { |
| 35 return [GetController(browser_) buttonCount]; | 36 return [GetController(browser_) buttonCount]; |
| 36 } | 37 } |
| 37 | 38 |
| 38 bool BrowserActionTestUtil::HasIcon(int index) { | 39 bool BrowserActionTestUtil::HasIcon(int index) { |
| 39 return [GetButton(browser_, index) image] != nil; | 40 return [GetButton(browser_, index) image] != nil; |
| 40 } | 41 } |
| 41 | 42 |
| 43 uint32 BrowserActionTestUtil::GetIconID(int index) { |
| 44 NSImage* ns_image = [GetButton(browser_, index) image]; |
| 45 // |ns_image| will be released by gfx::Image. Retain it here so it doesn't go |
| 46 // away prematurely. |
| 47 base::mac::NSObjectRetain(ns_image); |
| 48 return gfx::Image(ns_image).AsBitmap().getGenerationID(); |
| 49 } |
| 50 |
| 42 void BrowserActionTestUtil::Press(int index) { | 51 void BrowserActionTestUtil::Press(int index) { |
| 43 NSButton* button = GetButton(browser_, index); | 52 NSButton* button = GetButton(browser_, index); |
| 44 [button performClick:nil]; | 53 [button performClick:nil]; |
| 45 } | 54 } |
| 46 | 55 |
| 47 std::string BrowserActionTestUtil::GetTooltip(int index) { | 56 std::string BrowserActionTestUtil::GetTooltip(int index) { |
| 48 NSString* tooltip = [GetButton(browser_, index) toolTip]; | 57 NSString* tooltip = [GetButton(browser_, index) toolTip]; |
| 49 return base::SysNSStringToUTF8(tooltip); | 58 return base::SysNSStringToUTF8(tooltip); |
| 50 } | 59 } |
| 51 | 60 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 66 return !HasPopup(); | 75 return !HasPopup(); |
| 67 } | 76 } |
| 68 | 77 |
| 69 gfx::Size BrowserActionTestUtil::GetMinPopupSize() { | 78 gfx::Size BrowserActionTestUtil::GetMinPopupSize() { |
| 70 return gfx::Size(NSSizeToCGSize([ExtensionPopupController minPopupSize])); | 79 return gfx::Size(NSSizeToCGSize([ExtensionPopupController minPopupSize])); |
| 71 } | 80 } |
| 72 | 81 |
| 73 gfx::Size BrowserActionTestUtil::GetMaxPopupSize() { | 82 gfx::Size BrowserActionTestUtil::GetMaxPopupSize() { |
| 74 return gfx::Size(NSSizeToCGSize([ExtensionPopupController maxPopupSize])); | 83 return gfx::Size(NSSizeToCGSize([ExtensionPopupController maxPopupSize])); |
| 75 } | 84 } |
| OLD | NEW |