| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "build/build_config.h" | 6 #include "build/build_config.h" |
| 7 #include "chrome/browser/ui/test/test_browser_dialog.h" | 7 #include "chrome/browser/ui/test/test_browser_dialog.h" |
| 8 #include "chrome/common/chrome_result_codes.h" | 8 #include "chrome/common/chrome_result_codes.h" |
| 9 #include "chrome/common/chrome_switches.h" | 9 #include "chrome/common/chrome_switches.h" |
| 10 #include "chrome/test/base/in_process_browser_test.h" | 10 #include "chrome/test/base/in_process_browser_test.h" |
| 11 #include "ui/base/ui_base_switches.h" | 11 #include "ui/base/ui_base_switches.h" |
| 12 | 12 |
| 13 // Unfortunately, this needs to be Windows only for now. Even though this test | 13 // Unfortunately, this needs to be Windows only for now. Even though this test |
| 14 // is meant to exercise code that is for Windows only, it is a good general | 14 // is meant to exercise code that is for Windows only, it is a good general |
| 15 // canary in the coal mine for problems related to early shutdown (aborted | 15 // canary in the coal mine for problems related to early shutdown (aborted |
| 16 // startup). Sadly, it times out on platforms other than Windows, so I can't | 16 // startup). Sadly, it times out on platforms other than Windows, so I can't |
| 17 // enable it for those platforms at the moment. I hope one day our test harness | 17 // enable it for those platforms at the moment. I hope one day our test harness |
| 18 // will be improved to support this so we can get coverage on other platforms. | 18 // will be improved to support this so we can get coverage on other platforms. |
| 19 // See http://crbug.com/45115 for details. | 19 // See http://crbug.com/45115 for details. |
| 20 #if defined(OS_WIN) | 20 #if defined(OS_WIN) |
| 21 #include "chrome/browser/ui/views/try_chrome_dialog_view.h" | 21 #include "chrome/browser/ui/views/try_chrome_dialog.h" |
| 22 | 22 |
| 23 // By passing kTryChromeAgain with a magic value > 10000 we cause Chrome | 23 // By passing kTryChromeAgain with a magic value > 10000 we cause Chrome |
| 24 // to exit fairly early. | 24 // to exit fairly early. |
| 25 // Quickly exiting Chrome (regardless of this particular flag -- it | 25 // Quickly exiting Chrome (regardless of this particular flag -- it |
| 26 // doesn't do anything other than cause Chrome to quit on startup on | 26 // doesn't do anything other than cause Chrome to quit on startup on |
| 27 // non-Windows) was a cause of crashes (see bug 34799 for example) so | 27 // non-Windows) was a cause of crashes (see bug 34799 for example) so |
| 28 // this is a useful test of the startup/quick-shutdown cycle. | 28 // this is a useful test of the startup/quick-shutdown cycle. |
| 29 class TryChromeDialogBrowserTest : public InProcessBrowserTest { | 29 class TryChromeDialogBrowserTest : public InProcessBrowserTest { |
| 30 public: | 30 public: |
| 31 TryChromeDialogBrowserTest() { | 31 TryChromeDialogBrowserTest() { |
| 32 set_expected_exit_code(chrome::RESULT_CODE_NORMAL_EXIT_CANCEL); | 32 set_expected_exit_code(chrome::RESULT_CODE_NORMAL_EXIT_CANCEL); |
| 33 } | 33 } |
| 34 | 34 |
| 35 protected: | 35 protected: |
| 36 void SetUpCommandLine(base::CommandLine* command_line) override { | 36 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 37 command_line->AppendSwitchASCII(switches::kTryChromeAgain, "10001"); | 37 command_line->AppendSwitchASCII(switches::kTryChromeAgain, "10001"); |
| 38 } | 38 } |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 // Note to Sheriffs: This test (as you can read about above) simply causes | 41 // Note to Sheriffs: This test (as you can read about above) simply causes |
| 42 // Chrome to shutdown early, and, as such, has proven to be pretty good at | 42 // Chrome to shutdown early, and, as such, has proven to be pretty good at |
| 43 // finding problems related to shutdown. Sheriff, before marking this test as | 43 // finding problems related to shutdown. Sheriff, before marking this test as |
| 44 // disabled, please consider that this test is meant to catch when people | 44 // disabled, please consider that this test is meant to catch when people |
| 45 // introduce changes that crash Chrome during shutdown and disabling this test | 45 // introduce changes that crash Chrome during shutdown and disabling this test |
| 46 // and moving on removes a safeguard meant to avoid an even bigger thorny mess | 46 // and moving on removes a safeguard meant to avoid an even bigger thorny mess |
| (...skipping 16 matching lines...) Expand all Loading... |
| 63 public: | 63 public: |
| 64 // TODO(ananta) | 64 // TODO(ananta) |
| 65 // Provide a way to test flavors other than 0. | 65 // Provide a way to test flavors other than 0. |
| 66 TryChromeDialogTest() : dialog_(0) {} | 66 TryChromeDialogTest() : dialog_(0) {} |
| 67 | 67 |
| 68 static void DialogHandler(gfx::NativeWindow active_dialog) {} | 68 static void DialogHandler(gfx::NativeWindow active_dialog) {} |
| 69 | 69 |
| 70 // DialogBrowserTest: | 70 // DialogBrowserTest: |
| 71 void ShowDialog(const std::string& name) override { | 71 void ShowDialog(const std::string& name) override { |
| 72 dialog_.ShowDialog(base::Bind(&TryChromeDialogTest::DialogHandler), | 72 dialog_.ShowDialog(base::Bind(&TryChromeDialogTest::DialogHandler), |
| 73 TryChromeDialogView::kDialogType::MODELESS, | 73 TryChromeDialog::DialogType::MODELESS_FOR_TEST, |
| 74 TryChromeDialogView::kUsageType::FOR_TESTING); | 74 TryChromeDialog::UsageType::FOR_TESTING); |
| 75 } | 75 } |
| 76 | 76 |
| 77 // content::BrowserTestBase: | 77 // content::BrowserTestBase: |
| 78 void SetUpCommandLine(base::CommandLine* command_line) override { | 78 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 79 command_line->AppendSwitch(switches::kExtendMdToSecondaryUi); | 79 command_line->AppendSwitch(switches::kExtendMdToSecondaryUi); |
| 80 } | 80 } |
| 81 | 81 |
| 82 private: | 82 private: |
| 83 TryChromeDialogView dialog_; | 83 TryChromeDialog dialog_; |
| 84 | 84 |
| 85 DISALLOW_COPY_AND_ASSIGN(TryChromeDialogTest); | 85 DISALLOW_COPY_AND_ASSIGN(TryChromeDialogTest); |
| 86 }; | 86 }; |
| 87 | 87 |
| 88 IN_PROC_BROWSER_TEST_F(TryChromeDialogTest, InvokeDialog_default) { | 88 IN_PROC_BROWSER_TEST_F(TryChromeDialogTest, InvokeDialog_default) { |
| 89 RunDialog(); | 89 RunDialog(); |
| 90 } | 90 } |
| 91 | 91 |
| 92 #endif // defined(OS_WIN) | 92 #endif // defined(OS_WIN) |
| OLD | NEW |