Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1092)

Side by Side Diff: chrome/browser/cocoa/html_dialog_window_controller_unittest.mm

Issue 344008: Implemented most of HtmlDialogWindowController, which is a Cocoa port (Closed)
Patch Set: Added TODOs. Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/cocoa/html_dialog_window_controller.mm ('k') | chrome/chrome.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #import "chrome/browser/cocoa/html_dialog_window_controller.h"
6
7 #include <string>
8 #include <vector>
9
10 #import <Cocoa/Cocoa.h>
11
12 #include "base/gfx/size.h"
13 #import "base/scoped_nsautorelease_pool.h"
14 #include "base/sys_string_conversions.h"
15 #include "chrome/browser/cocoa/cocoa_test_helper.h"
16 #include "chrome/browser/dom_ui/dom_ui.h"
17 #include "chrome/browser/dom_ui/html_dialog_ui.h"
18 #include "chrome/test/browser_with_test_window_test.h"
19 #include "googleurl/src/gurl.h"
20 #include "testing/gmock/include/gmock/gmock.h"
21 #include "testing/gtest/include/gtest/gtest.h"
22
23 namespace {
24
25 class MockDelegate : public HtmlDialogUIDelegate {
26 public:
27 MOCK_CONST_METHOD0(IsDialogModal, bool());
28 MOCK_CONST_METHOD0(GetDialogTitle, std::wstring());
29 MOCK_CONST_METHOD0(GetDialogContentURL, GURL());
30 MOCK_CONST_METHOD1(GetDOMMessageHandlers,
31 void(std::vector<DOMMessageHandler*>*));
32 MOCK_CONST_METHOD1(GetDialogSize, void(gfx::Size*));
33 MOCK_CONST_METHOD0(GetDialogArgs, std::string());
34 MOCK_METHOD1(OnDialogClosed, void(const std::string& json_retval));
35 };
36
37 class HtmlDialogWindowControllerTest : public BrowserWithTestWindowTest {
38 public:
39 virtual void SetUp() {
40 BrowserWithTestWindowTest::SetUp();
41 title_ = L"Mock Title";
42 size_ = gfx::Size(50, 100);
43 gurl_ = GURL("");
44 }
45
46 protected:
47 std::wstring title_;
48 gfx::Size size_;
49 GURL gurl_;
50
51 // Order here is important.
52 CocoaTestHelper cocoa_helper_;
53 MockDelegate delegate_;
54 };
55
56 using ::testing::_;
57 using ::testing::Return;
58 using ::testing::SetArgumentPointee;
59
60 // TODO(akalin): We can't test much more than the below without a real browser.
61 // In particular, GetDOMMessageHandlers() and GetDialogArgs() are never called.
62 // This should be fixed.
63
64 TEST_F(HtmlDialogWindowControllerTest, showDialog) {
65 // We want to make sure html_dialog_window_controller below gets
66 // destroyed before cocoa_helper_ and delegate_, so we specify our
67 // own autorelease pool.
68 //
69 // TODO(dmaclach): Remove this once
70 // http://code.google.com/p/chromium/issues/detail?id=26133 is fixed.
71 base::ScopedNSAutoreleasePool release_pool;
72
73 EXPECT_CALL(delegate_, GetDialogTitle())
74 .WillOnce(Return(title_));
75 EXPECT_CALL(delegate_, GetDialogSize(_))
76 .WillOnce(SetArgumentPointee<0>(size_));
77 EXPECT_CALL(delegate_, GetDialogContentURL())
78 .WillOnce(Return(gurl_));
79 EXPECT_CALL(delegate_, OnDialogClosed(_))
80 .Times(1);
81
82 NSWindow* parent_window = cocoa_helper_.window();
83 HtmlDialogWindowController* html_dialog_window_controller =
84 [[HtmlDialogWindowController alloc] initWithDelegate:&delegate_
85 parentWindow:parent_window
86 browser:browser()];
87
88 [html_dialog_window_controller loadDialogContents];
89 [html_dialog_window_controller showWindow:nil];
90 [html_dialog_window_controller close];
91 }
92
93 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/html_dialog_window_controller.mm ('k') | chrome/chrome.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698