15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2010 The Chromium Authors. All rights reserved. 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file. 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef CHROME_BROWSER_EXTENSIONS_BROWSER_ACTION_TEST_UTIL_H_ 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define CHROME_BROWSER_EXTENSIONS_BROWSER_ACTION_TEST_UTIL_H_ 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <string> 95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "build/build_config.h" 115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class Browser; 135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class ExtensionAction; 145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace gfx { 165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class Image; 175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class Rect; 185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class Size; 195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} // namespace gfx 205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class BrowserActionTestUtil { 225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public: 235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) explicit BrowserActionTestUtil(Browser* browser) : browser_(browser) {} 245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the number of browser action buttons in the window toolbar. 265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int NumberOfBrowserActions(); 275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the number of browser action currently visible. 295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int VisibleBrowserActions(); 305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(TOOLKIT_VIEWS) 325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the ExtensionAction for the given index. 335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ExtensionAction* GetExtensionAction(int index); 345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif 355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns whether the browser action at |index| has a non-null icon. Note 375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // that the icon is loaded asynchronously, in which case you can wait for it 385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // to load by calling WaitForBrowserActionUpdated. 395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool HasIcon(int index); 405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns icon for the browser action at |index|. 425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Image GetIcon(int index); 435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Simulates a user click on the browser action button at |index|. 455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void Press(int index); 465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the extension id of the extension at |index|. 485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) std::string GetExtensionId(int index); 495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the current tooltip for the browser action button. 515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) std::string GetTooltip(int index); 525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns whether a browser action popup is being shown currently. 545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool HasPopup(); 555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the bounds of the current browser action popup. 575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect GetPopupBounds(); 585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Hides the given popup and returns whether the hide was successful. 605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool HidePopup(); 615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Set how many icons should be visible. 635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void SetIconVisibilityCount(size_t icons); 645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the minimum allowed size of an extension popup. 665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static gfx::Size GetMinPopupSize(); 675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the maximum allowed size of an extension popup. 695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static gfx::Size GetMaxPopupSize(); 705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) private: 725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Browser* browser_; // weak 735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif // CHROME_BROWSER_EXTENSIONS_BROWSER_ACTION_TEST_UTIL_H_ 76