| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #import "chrome/browser/ui/cocoa/html_dialog_window_controller.h" | 5 #import "chrome/browser/ui/cocoa/html_dialog_window_controller.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #import <Cocoa/Cocoa.h> | 10 #import <Cocoa/Cocoa.h> |
| 11 | 11 |
| 12 #import "base/mac/scoped_nsautorelease_pool.h" | 12 #import "base/mac/scoped_nsautorelease_pool.h" |
| 13 #include "base/sys_string_conversions.h" | 13 #include "base/sys_string_conversions.h" |
| 14 #include "base/utf_string_conversions.h" |
| 14 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
| 15 #include "chrome/browser/ui/cocoa/cocoa_test_helper.h" | 16 #include "chrome/browser/ui/cocoa/cocoa_test_helper.h" |
| 16 #include "chrome/browser/ui/webui/html_dialog_ui.h" | 17 #include "chrome/browser/ui/webui/html_dialog_ui.h" |
| 17 #include "chrome/test/base/browser_with_test_window_test.h" | 18 #include "chrome/test/base/browser_with_test_window_test.h" |
| 18 #include "chrome/test/base/testing_profile.h" | 19 #include "chrome/test/base/testing_profile.h" |
| 19 #include "content/browser/webui/web_ui.h" | 20 #include "content/browser/webui/web_ui.h" |
| 20 #include "googleurl/src/gurl.h" | 21 #include "googleurl/src/gurl.h" |
| 21 #include "testing/gmock/include/gmock/gmock.h" | 22 #include "testing/gmock/include/gmock/gmock.h" |
| 22 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
| 23 #include "ui/gfx/size.h" | 24 #include "ui/gfx/size.h" |
| 24 | 25 |
| 25 namespace { | 26 namespace { |
| 26 | 27 |
| 27 class MockDelegate : public HtmlDialogUIDelegate { | 28 class MockDelegate : public HtmlDialogUIDelegate { |
| 28 public: | 29 public: |
| 29 MOCK_CONST_METHOD0(IsDialogModal, bool()); | 30 MOCK_CONST_METHOD0(IsDialogModal, bool()); |
| 30 MOCK_CONST_METHOD0(GetDialogTitle, std::wstring()); | 31 MOCK_CONST_METHOD0(GetDialogTitle, string16()); |
| 31 MOCK_CONST_METHOD0(GetDialogContentURL, GURL()); | 32 MOCK_CONST_METHOD0(GetDialogContentURL, GURL()); |
| 32 MOCK_CONST_METHOD1(GetWebUIMessageHandlers, | 33 MOCK_CONST_METHOD1(GetWebUIMessageHandlers, |
| 33 void(std::vector<WebUIMessageHandler*>*)); | 34 void(std::vector<WebUIMessageHandler*>*)); |
| 34 MOCK_CONST_METHOD1(GetDialogSize, void(gfx::Size*)); | 35 MOCK_CONST_METHOD1(GetDialogSize, void(gfx::Size*)); |
| 35 MOCK_CONST_METHOD0(GetDialogArgs, std::string()); | 36 MOCK_CONST_METHOD0(GetDialogArgs, std::string()); |
| 36 MOCK_METHOD1(OnDialogClosed, void(const std::string& json_retval)); | 37 MOCK_METHOD1(OnDialogClosed, void(const std::string& json_retval)); |
| 37 MOCK_METHOD2(OnCloseContents, | 38 MOCK_METHOD2(OnCloseContents, |
| 38 void(TabContents* source, bool* out_close_dialog)); | 39 void(TabContents* source, bool* out_close_dialog)); |
| 39 MOCK_CONST_METHOD0(ShouldShowDialogTitle, bool()); | 40 MOCK_CONST_METHOD0(ShouldShowDialogTitle, bool()); |
| 40 }; | 41 }; |
| 41 | 42 |
| 42 class HtmlDialogWindowControllerTest : public BrowserWithTestWindowTest { | 43 class HtmlDialogWindowControllerTest : public BrowserWithTestWindowTest { |
| 43 public: | 44 public: |
| 44 virtual void SetUp() { | 45 virtual void SetUp() { |
| 45 BrowserWithTestWindowTest::SetUp(); | 46 BrowserWithTestWindowTest::SetUp(); |
| 46 CocoaTest::BootstrapCocoa(); | 47 CocoaTest::BootstrapCocoa(); |
| 47 title_ = L"Mock Title"; | 48 title_ = ASCIIToUTF16("Mock Title"); |
| 48 size_ = gfx::Size(50, 100); | 49 size_ = gfx::Size(50, 100); |
| 49 gurl_ = GURL(""); | 50 gurl_ = GURL(""); |
| 50 } | 51 } |
| 51 | 52 |
| 52 protected: | 53 protected: |
| 53 std::wstring title_; | 54 string16 title_; |
| 54 gfx::Size size_; | 55 gfx::Size size_; |
| 55 GURL gurl_; | 56 GURL gurl_; |
| 56 | 57 |
| 57 // Order here is important. | 58 // Order here is important. |
| 58 MockDelegate delegate_; | 59 MockDelegate delegate_; |
| 59 }; | 60 }; |
| 60 | 61 |
| 61 using ::testing::_; | 62 using ::testing::_; |
| 62 using ::testing::Return; | 63 using ::testing::Return; |
| 63 using ::testing::SetArgumentPointee; | 64 using ::testing::SetArgumentPointee; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 86 HtmlDialogWindowController* html_dialog_window_controller = | 87 HtmlDialogWindowController* html_dialog_window_controller = |
| 87 [[HtmlDialogWindowController alloc] initWithDelegate:&delegate_ | 88 [[HtmlDialogWindowController alloc] initWithDelegate:&delegate_ |
| 88 profile:profile()]; | 89 profile:profile()]; |
| 89 | 90 |
| 90 [html_dialog_window_controller loadDialogContents]; | 91 [html_dialog_window_controller loadDialogContents]; |
| 91 [html_dialog_window_controller showWindow:nil]; | 92 [html_dialog_window_controller showWindow:nil]; |
| 92 [html_dialog_window_controller close]; | 93 [html_dialog_window_controller close]; |
| 93 } | 94 } |
| 94 | 95 |
| 95 } // namespace | 96 } // namespace |
| OLD | NEW |