try_chrome_dialog_view_browsertest.cc revision 5821806d5e7f356e8fa4b058a389a808ea183019
15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 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)#include "base/command_line.h" 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/common/chrome_switches.h" 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/test/base/in_process_browser_test.h" 85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Unfortunately, this needs to be Windows only for now. Even though this test 105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// is meant to exercise code that is for Windows only, it is a good general 115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// canary in the coal mine for problems related to early shutdown (aborted 125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// startup). Sadly, it times out on platforms other than Windows, so I can't 135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// enable it for those platforms at the moment. I hope one day our test harness 145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// will be improved to support this so we can get coverage on other platforms. 155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// See http://crbug.com/45115 for details. 165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_WIN) 175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// By passing kTryChromeAgain with a magic value > 10000 we cause Chrome 195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// to exit fairly early. 205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Quickly exiting Chrome (regardless of this particular flag -- it 215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// doesn't do anything other than cause Chrome to quit on startup on 225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// non-Windows) was a cause of crashes (see bug 34799 for example) so 235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// this is a useful test of the startup/quick-shutdown cycle. 245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class TryChromeDialogBrowserTest : public InProcessBrowserTest { 255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)public: 265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) TryChromeDialogBrowserTest() {} 275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)protected: 295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void SetUpCommandLine(CommandLine* command_line) { 305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) command_line->AppendSwitchASCII(switches::kTryChromeAgain, "10001"); 315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Note to Sheriffs: This test (as you can read about above) simply causes 355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Chrome to shutdown early, and, as such, has proven to be pretty good at 365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// finding problems related to shutdown. Sheriff, before marking this test as 375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// disabled, please consider that this test is meant to catch when people 385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// introduce changes that crash Chrome during shutdown and disabling this test 395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// and moving on removes a safeguard meant to avoid an even bigger thorny mess 405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// to untangle much later down the line. Disabling the test also means that the 415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// people who get blamed are not the ones that introduced the crash (in other 425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// words, don't shoot the messenger). So, please help us avoid additional 435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// shutdown crashes from creeping in, by doing the following: 445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Run chrome.exe --try-chrome-again=10001. This is all that the test does and 455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// should be enough to trigger the failure. If it is a crash (most likely) then 465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// look at the callstack and see if any of the components have been touched 475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// recently. Look at recent changes to startup, such as any change to 485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// ChromeBrowserMainParts, specifically PreCreateThreadsImpl and see if someone 495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// has been reordering code blocks for startup. Try reverting any suspicious 505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// changes to see if it affects the test. History shows that waiting until later 515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// only makes the problem worse. 525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(TryChromeDialogBrowserTest, ToastCrasher) {} 535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif // defined(OS_WIN) 55