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/common/chrome_result_codes.h" | 8 #include "chrome/common/chrome_result_codes.h" |
8 #include "chrome/common/chrome_switches.h" | 9 #include "chrome/common/chrome_switches.h" |
9 #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" |
10 | 12 |
11 // 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 |
12 // 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 |
13 // 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 |
14 // 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 |
15 // 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 |
16 // 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. |
17 // See http://crbug.com/45115 for details. | 19 // See http://crbug.com/45115 for details. |
18 #if defined(OS_WIN) | 20 #if defined(OS_WIN) |
| 21 #include "chrome/browser/ui/views/try_chrome_dialog_view.h" |
19 | 22 |
20 // By passing kTryChromeAgain with a magic value > 10000 we cause Chrome | 23 // By passing kTryChromeAgain with a magic value > 10000 we cause Chrome |
21 // to exit fairly early. | 24 // to exit fairly early. |
22 // Quickly exiting Chrome (regardless of this particular flag -- it | 25 // Quickly exiting Chrome (regardless of this particular flag -- it |
23 // 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 |
24 // 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 |
25 // this is a useful test of the startup/quick-shutdown cycle. | 28 // this is a useful test of the startup/quick-shutdown cycle. |
26 class TryChromeDialogBrowserTest : public InProcessBrowserTest { | 29 class TryChromeDialogBrowserTest : public InProcessBrowserTest { |
27 public: | 30 public: |
28 TryChromeDialogBrowserTest() { | 31 TryChromeDialogBrowserTest() { |
(...skipping 19 matching lines...) Expand all Loading... |
48 // Run chrome.exe --try-chrome-again=10001. This is all that the test does and | 51 // Run chrome.exe --try-chrome-again=10001. This is all that the test does and |
49 // should be enough to trigger the failure. If it is a crash (most likely) then | 52 // should be enough to trigger the failure. If it is a crash (most likely) then |
50 // look at the callstack and see if any of the components have been touched | 53 // look at the callstack and see if any of the components have been touched |
51 // recently. Look at recent changes to startup, such as any change to | 54 // recently. Look at recent changes to startup, such as any change to |
52 // ChromeBrowserMainParts, specifically PreCreateThreadsImpl and see if someone | 55 // ChromeBrowserMainParts, specifically PreCreateThreadsImpl and see if someone |
53 // has been reordering code blocks for startup. Try reverting any suspicious | 56 // has been reordering code blocks for startup. Try reverting any suspicious |
54 // changes to see if it affects the test. History shows that waiting until later | 57 // changes to see if it affects the test. History shows that waiting until later |
55 // only makes the problem worse. | 58 // only makes the problem worse. |
56 IN_PROC_BROWSER_TEST_F(TryChromeDialogBrowserTest, ToastCrasher) {} | 59 IN_PROC_BROWSER_TEST_F(TryChromeDialogBrowserTest, ToastCrasher) {} |
57 | 60 |
| 61 // Helper class to display the TryChromeDialog for testing. |
| 62 class TryChromeDialogTest : public DialogBrowserTest { |
| 63 public: |
| 64 // TODO(ananta) |
| 65 // Provide a way to test flavors other than 0. |
| 66 TryChromeDialogTest() : dialog_(0) {} |
| 67 |
| 68 static void DialogHandler(gfx::NativeWindow active_dialog) {} |
| 69 |
| 70 // DialogBrowserTest: |
| 71 void ShowDialog(const std::string& name) override { |
| 72 dialog_.ShowDialog(base::Bind(&TryChromeDialogTest::DialogHandler), |
| 73 TryChromeDialogView::kDialogType::MODELESS, |
| 74 TryChromeDialogView::kUsageType::FOR_TESTING); |
| 75 } |
| 76 |
| 77 // content::BrowserTestBase: |
| 78 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 79 command_line->AppendSwitch(switches::kExtendMdToSecondaryUi); |
| 80 } |
| 81 |
| 82 private: |
| 83 TryChromeDialogView dialog_; |
| 84 |
| 85 DISALLOW_COPY_AND_ASSIGN(TryChromeDialogTest); |
| 86 }; |
| 87 |
| 88 IN_PROC_BROWSER_TEST_F(TryChromeDialogTest, InvokeDialog_default) { |
| 89 RunDialog(); |
| 90 } |
| 91 |
58 #endif // defined(OS_WIN) | 92 #endif // defined(OS_WIN) |
OLD | NEW |