From 81ccef9d2941a3b6708564b634f6e79f00bc6ab9 Mon Sep 17 00:00:00 2001 From: "pam@chromium.org" Date: Mon, 20 Apr 2009 23:14:18 +0000 Subject: Disable check for active window when it doesn't look like Chromium is the front app. This should fix the buildbots but still allow a manual test. TBR=erikkay BUG=5278 TEST=run ui_tests with another app at the front. Make sure TabRestoreUITest.* pass with no "is_active" failures. Review URL: http://codereview.chromium.org/88012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14068 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/tab_restore_uitest.cc | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/chrome/browser/tab_restore_uitest.cc b/chrome/browser/tab_restore_uitest.cc index 109c768..7c7956f 100644 --- a/chrome/browser/tab_restore_uitest.cc +++ b/chrome/browser/tab_restore_uitest.cc @@ -52,13 +52,27 @@ class TabRestoreUITest : public UITest { // Ensure that the given browser occupies the currently active window. void CheckActiveWindow(const BrowserProxy* browser) { - // The EXPECT_TRUE may fail during manual debugging, as well as if a user - // does other things while running the tests, because Chromium won't be - // the foremost application at all. bool is_active = false; scoped_ptr window_proxy(browser->GetWindow()); ASSERT_TRUE(window_proxy->IsActive(&is_active)); - EXPECT_TRUE(is_active); + // The EXPECT_TRUE may fail if other apps are active while running the + // tests, because Chromium won't be the foremost application at all. To + // prevent this from turning the buildbots red, we disable the check + // entirely if it failed the first time we tried it. Thus the first + // CheckActiveWindow() call we encounter should be in a situation that's + // virtually guaranteed to be correct. + static int check_flag = 0; // 0 = first run, -1 = don't check, 1 = do check + if (!check_flag) { + if (is_active) { + check_flag = 1; + } else { + check_flag = -1; + LOG(ERROR) << "CheckActiveWindow disabled for all TabRestoreUITest.*" + " because Chromium is not the front app."; + } + } + if (check_flag == 1) + EXPECT_TRUE(is_active); } GURL url1_; @@ -150,6 +164,9 @@ TEST_F(TabRestoreUITest, MiddleTab) { TEST_F(TabRestoreUITest, RestoreToDifferentWindow) { scoped_ptr browser_proxy(automation()->GetBrowserWindow(0)); + // This call is virtually guaranteed to pass, assuming that Chromium is the + // active application, which will establish a baseline for later calls to + // CheckActiveWindow(). See comments in that function. CheckActiveWindow(browser_proxy.get()); int tab_count; -- cgit v1.1