15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2011 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_TASK_MANAGER_TASK_MANAGER_BROWSERTEST_UTIL_H_ 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_BROWSERTEST_UTIL_H_ 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "base/strings/string16.h" 95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 10a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)namespace task_manager { 11a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)namespace browsertest_util { 125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 13a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Runs the message loop, observing the task manager, until there are exactly 14a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// |resource_count| many resources whose titles match the pattern 15a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// |title_pattern|. The match is done via string_util's base::MatchPattern, so 16a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// |title_pattern| may contain wildcards like "*". 17a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// 18a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// If the wait times out, this test will trigger a gtest failure. To get 19a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// meaningful errors, tests should wrap invocations of this function with 20a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// ASSERT_NO_FATAL_FAILURE(). 21a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void WaitForTaskManagerRows(int resource_count, 22a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) const base::string16& title_pattern); 23a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 24a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// ASCII matcher convenience functions for use with WaitForTaskManagerRows() 25a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)base::string16 MatchTab(const char* title); // "Tab: " + title 26a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)base::string16 MatchAnyTab(); // "Tab: *" 27a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)base::string16 MatchAboutBlankTab(); // "Tab: about:blank" 28a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)base::string16 MatchExtension(const char* title); // "Extension: " + title 29a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)base::string16 MatchAnyExtension(); // "Extension: *" 30a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)base::string16 MatchApp(const char* title); // "App: " + title 31a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)base::string16 MatchAnyApp(); // "App: *" 32a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)base::string16 MatchWebView(const char* title); // "WebView: " + title 33a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)base::string16 MatchAnyWebView(); // "WebView: *" 34a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)base::string16 MatchBackground(const char* title); // "Background: " + title 35a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)base::string16 MatchAnyBackground(); // "Background: *" 36e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdochbase::string16 MatchPrint(const char* title); // "Print: " + title 37e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdochbase::string16 MatchAnyPrint(); // "Print: *" 38a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 39a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} // namespace browsertest_util 40a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} // namespace task_manager 415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif // CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_BROWSERTEST_UTIL_H_ 43