OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/command_line.h" | |
9 #include "base/values.h" | 10 #include "base/values.h" |
11 #include "chrome/common/chrome_switches.h" | |
10 #include "chrome/common/url_constants.h" | 12 #include "chrome/common/url_constants.h" |
11 #include "chrome/test/base/ui_test_utils.h" | 13 #include "chrome/test/base/ui_test_utils.h" |
12 #include "chrome/test/base/web_ui_browser_test.h" | 14 #include "chrome/test/base/web_ui_browser_test.h" |
13 #include "content/public/browser/web_ui.h" | 15 #include "content/public/browser/web_ui.h" |
14 #include "content/public/browser/web_ui_message_handler.h" | 16 #include "content/public/browser/web_ui_message_handler.h" |
15 #include "testing/gmock/include/gmock/gmock.h" | 17 #include "testing/gmock/include/gmock/gmock.h" |
16 #include "testing/gtest/include/gtest/gtest-spi.h" | 18 #include "testing/gtest/include/gtest/gtest-spi.h" |
17 | 19 |
18 using content::WebUIMessageHandler; | 20 using content::WebUIMessageHandler; |
19 | 21 |
20 // According to the interface for EXPECT_FATAL_FAILURE | 22 // According to the interface for EXPECT_FATAL_FAILURE |
21 // (http://code.google.com/p/googletest/wiki/AdvancedGuide#Catching_Failures) | 23 // (http://code.google.com/p/googletest/wiki/AdvancedGuide#Catching_Failures) |
22 // the statement must be statically available. Therefore, we make a static | 24 // the statement must be statically available. Therefore, we make a static |
23 // global s_test_ which should point to |this| for the duration of the test run | 25 // global s_test_ which should point to |this| for the duration of the test run |
24 // and be cleared afterward. | 26 // and be cleared afterward. |
25 class WebUIBrowserExpectFailTest : public WebUIBrowserTest { | 27 class WebUIBrowserExpectFailTest : public WebUIBrowserTest { |
26 public: | 28 public: |
27 WebUIBrowserExpectFailTest() { | 29 WebUIBrowserExpectFailTest() { |
28 EXPECT_FALSE(s_test_); | 30 EXPECT_FALSE(s_test_); |
29 s_test_ = this; | 31 s_test_ = this; |
30 } | 32 } |
31 | 33 |
34 // Disable new downloads UI as it is very very slow. | |
Lei Zhang
2015/09/01 22:41:07
// Disable new downloads UI as it is very very slo
benwells
2015/09/01 23:06:11
Done.
| |
35 // TODO(dbeam): remove this once the downloads UI is not slow. | |
36 void SetUpCommandLine(base::CommandLine* command_line) override { | |
37 WebUIBrowserTest::SetUpCommandLine(command_line); | |
38 command_line->AppendSwitch(switches::kDisableMaterialDesignDownloads); | |
39 } | |
40 | |
32 protected: | 41 protected: |
33 ~WebUIBrowserExpectFailTest() override { | 42 ~WebUIBrowserExpectFailTest() override { |
34 EXPECT_TRUE(s_test_); | 43 EXPECT_TRUE(s_test_); |
35 s_test_ = NULL; | 44 s_test_ = NULL; |
36 } | 45 } |
37 | 46 |
38 static void RunJavascriptTestNoReturn(const std::string& testname) { | 47 static void RunJavascriptTestNoReturn(const std::string& testname) { |
39 EXPECT_TRUE(s_test_); | 48 EXPECT_TRUE(s_test_); |
40 s_test_->RunJavascriptTest(testname); | 49 s_test_->RunJavascriptTest(testname); |
41 } | 50 } |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
236 // testDone directly and expect pass result. | 245 // testDone directly and expect pass result. |
237 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPassesAsync) { | 246 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPassesAsync) { |
238 ASSERT_TRUE(RunJavascriptAsyncTest("testDone")); | 247 ASSERT_TRUE(RunJavascriptAsyncTest("testDone")); |
239 } | 248 } |
240 | 249 |
241 // Test that calling testDone during RunJavascriptTest still completes when | 250 // Test that calling testDone during RunJavascriptTest still completes when |
242 // waiting for async result. | 251 // waiting for async result. |
243 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPasses) { | 252 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPasses) { |
244 ASSERT_TRUE(RunJavascriptTest("testDone")); | 253 ASSERT_TRUE(RunJavascriptTest("testDone")); |
245 } | 254 } |
OLD | NEW |