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/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
6 #include "chrome/browser/ui/browser.h" | 6 #include "chrome/browser/ui/browser.h" |
7 #include "chrome/browser/ui/webui/test_html_dialog_ui_delegate.h" | 7 #include "chrome/browser/ui/webui/test_web_dialog_delegate.h" |
8 #include "chrome/common/url_constants.h" | 8 #include "chrome/common/url_constants.h" |
9 #include "chrome/test/base/in_process_browser_test.h" | 9 #include "chrome/test/base/in_process_browser_test.h" |
10 #include "chrome/test/base/ui_test_utils.h" | 10 #include "chrome/test/base/ui_test_utils.h" |
11 #include "testing/gmock/include/gmock/gmock.h" | 11 #include "testing/gmock/include/gmock/gmock.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
13 | 13 |
14 namespace { | 14 namespace { |
15 | 15 |
16 class TestDialogClosedDelegate : public test::TestHtmlDialogUIDelegate { | 16 class TestDialogClosedDelegate : public test::TestWebDialogDelegate { |
17 public: | 17 public: |
18 TestDialogClosedDelegate() | 18 TestDialogClosedDelegate() |
19 : test::TestHtmlDialogUIDelegate(GURL(chrome::kChromeUIChromeURLsURL)), | 19 : test::TestWebDialogDelegate( |
| 20 GURL(chrome::kChromeUIChromeURLsURL)), |
20 dialog_closed_(false) { | 21 dialog_closed_(false) { |
21 } | 22 } |
22 | 23 |
23 // Overridden from HtmlDialogUIDelegate: | 24 bool dialog_closed() const { return dialog_closed_; } |
| 25 |
| 26 // Overridden from WebDialogDelegate: |
24 virtual ui::ModalType GetDialogModalType() const OVERRIDE { | 27 virtual ui::ModalType GetDialogModalType() const OVERRIDE { |
25 return ui::MODAL_TYPE_NONE; | 28 return ui::MODAL_TYPE_NONE; |
26 } | 29 } |
27 | |
28 // Overridden from HtmlDialogUIDelegate: | |
29 virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE { | 30 virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE { |
30 dialog_closed_ = true; | 31 dialog_closed_ = true; |
31 } | 32 } |
32 | 33 |
33 bool dialog_closed() { | |
34 return dialog_closed_; | |
35 } | |
36 | |
37 private: | 34 private: |
38 bool dialog_closed_; | 35 bool dialog_closed_; |
| 36 |
| 37 DISALLOW_COPY_AND_ASSIGN(TestDialogClosedDelegate); |
39 }; | 38 }; |
40 | 39 |
41 } // namespace | 40 } // namespace |
42 | 41 |
43 class HtmlDialogControllerBrowserTest : public InProcessBrowserTest { | 42 class WebDialogControllerBrowserTest : public InProcessBrowserTest { |
44 public: | 43 public: |
45 HtmlDialogControllerBrowserTest() {} | 44 WebDialogControllerBrowserTest() {} |
46 }; | 45 }; |
47 | 46 |
48 // Tests that an HtmlDialog can be shown for an incognito browser and that when | 47 // Tests that a WebDialog can be shown for an incognito browser and that when |
49 // that browser is closed the dialog created by that browser is closed. | 48 // that browser is closed the dialog created by that browser is closed. |
50 IN_PROC_BROWSER_TEST_F(HtmlDialogControllerBrowserTest, IncognitoBrowser) { | 49 IN_PROC_BROWSER_TEST_F(WebDialogControllerBrowserTest, IncognitoBrowser) { |
51 Browser* browser = CreateIncognitoBrowser(); | 50 Browser* browser = CreateIncognitoBrowser(); |
52 scoped_ptr<TestDialogClosedDelegate> delegate(new TestDialogClosedDelegate()); | 51 scoped_ptr<TestDialogClosedDelegate> delegate(new TestDialogClosedDelegate()); |
53 | 52 |
54 // Create the dialog and make sure the initial "closed" state is what we | 53 // Create the dialog and make sure the initial "closed" state is what we |
55 // expect. | 54 // expect. |
56 browser->BrowserShowHtmlDialog(delegate.get(), NULL, STYLE_GENERIC); | 55 browser->BrowserShowWebDialog(delegate.get(), NULL, STYLE_GENERIC); |
57 ui_test_utils::RunAllPendingInMessageLoop(); | 56 ui_test_utils::RunAllPendingInMessageLoop(); |
58 ASSERT_FALSE(delegate->dialog_closed()); | 57 ASSERT_FALSE(delegate->dialog_closed()); |
59 | 58 |
60 // Closing the browser should close the dialogs associated with that browser. | 59 // Closing the browser should close the dialogs associated with that browser. |
61 browser->CloseWindow(); | 60 browser->CloseWindow(); |
62 ui_test_utils::RunAllPendingInMessageLoop(); | 61 ui_test_utils::RunAllPendingInMessageLoop(); |
63 ASSERT_TRUE(delegate->dialog_closed()); | 62 ASSERT_TRUE(delegate->dialog_closed()); |
64 } | 63 } |
OLD | NEW |