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" | |
8 #include "chrome/common/chrome_result_codes.h" | 7 #include "chrome/common/chrome_result_codes.h" |
9 #include "chrome/common/chrome_switches.h" | 8 #include "chrome/common/chrome_switches.h" |
10 #include "chrome/test/base/in_process_browser_test.h" | 9 #include "chrome/test/base/in_process_browser_test.h" |
11 #include "ui/base/ui_base_switches.h" | |
12 | 10 |
13 // Unfortunately, this needs to be Windows only for now. Even though this test | 11 // 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 | 12 // 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 | 13 // 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 | 14 // 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 | 15 // 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. | 16 // will be improved to support this so we can get coverage on other platforms. |
19 // See http://crbug.com/45115 for details. | 17 // See http://crbug.com/45115 for details. |
20 #if defined(OS_WIN) | 18 #if defined(OS_WIN) |
21 #include "chrome/browser/ui/views/try_chrome_dialog_view.h" | |
22 | 19 |
23 // By passing kTryChromeAgain with a magic value > 10000 we cause Chrome | 20 // By passing kTryChromeAgain with a magic value > 10000 we cause Chrome |
24 // to exit fairly early. | 21 // to exit fairly early. |
25 // Quickly exiting Chrome (regardless of this particular flag -- it | 22 // Quickly exiting Chrome (regardless of this particular flag -- it |
26 // doesn't do anything other than cause Chrome to quit on startup on | 23 // 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 | 24 // 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. | 25 // this is a useful test of the startup/quick-shutdown cycle. |
29 class TryChromeDialogBrowserTest : public InProcessBrowserTest { | 26 class TryChromeDialogBrowserTest : public InProcessBrowserTest { |
30 public: | 27 public: |
31 TryChromeDialogBrowserTest() { | 28 TryChromeDialogBrowserTest() { |
(...skipping 19 matching lines...) Expand all Loading... |
51 // Run chrome.exe --try-chrome-again=10001. This is all that the test does and | 48 // Run chrome.exe --try-chrome-again=10001. This is all that the test does and |
52 // should be enough to trigger the failure. If it is a crash (most likely) then | 49 // should be enough to trigger the failure. If it is a crash (most likely) then |
53 // look at the callstack and see if any of the components have been touched | 50 // look at the callstack and see if any of the components have been touched |
54 // recently. Look at recent changes to startup, such as any change to | 51 // recently. Look at recent changes to startup, such as any change to |
55 // ChromeBrowserMainParts, specifically PreCreateThreadsImpl and see if someone | 52 // ChromeBrowserMainParts, specifically PreCreateThreadsImpl and see if someone |
56 // has been reordering code blocks for startup. Try reverting any suspicious | 53 // has been reordering code blocks for startup. Try reverting any suspicious |
57 // changes to see if it affects the test. History shows that waiting until later | 54 // changes to see if it affects the test. History shows that waiting until later |
58 // only makes the problem worse. | 55 // only makes the problem worse. |
59 IN_PROC_BROWSER_TEST_F(TryChromeDialogBrowserTest, ToastCrasher) {} | 56 IN_PROC_BROWSER_TEST_F(TryChromeDialogBrowserTest, ToastCrasher) {} |
60 | 57 |
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 | |
92 #endif // defined(OS_WIN) | 58 #endif // defined(OS_WIN) |
OLD | NEW |