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/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
7 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" | 7 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" |
8 #import "chrome/browser/ui/cocoa/hyperlink_button_cell.h" | 8 #import "chrome/browser/ui/cocoa/hyperlink_button_cell.h" |
9 #import "chrome/browser/ui/cocoa/info_bubble_window.h" | 9 #import "chrome/browser/ui/cocoa/info_bubble_window.h" |
10 #import "chrome/browser/ui/cocoa/web_intent_sheet_controller.h" | 10 #import "chrome/browser/ui/cocoa/web_intent_sheet_controller.h" |
11 #include "chrome/browser/ui/cocoa/web_intent_picker_cocoa.h" | 11 #include "chrome/browser/ui/cocoa/web_intent_picker_cocoa.h" |
12 #include "chrome/browser/ui/intents/web_intent_picker_delegate.h" | 12 #include "chrome/browser/ui/intents/web_intent_picker_delegate.h" |
13 #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h" | 13 #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h" |
14 #include "content/browser/tab_contents/test_tab_contents.h" | 14 #include "content/browser/tab_contents/test_tab_contents.h" |
15 #include "content/test/test_browser_thread.h" | 15 #include "content/test/test_browser_thread.h" |
16 #include "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
17 | 17 |
18 namespace { | 18 namespace { |
19 | 19 |
20 class MockIntentPickerDelegate : public WebIntentPickerDelegate { | 20 class MockIntentPickerDelegate : public WebIntentPickerDelegate { |
21 public: | 21 public: |
22 virtual ~MockIntentPickerDelegate() {} | 22 virtual ~MockIntentPickerDelegate() {} |
23 | 23 |
24 MOCK_METHOD2(OnServiceChosen, void(size_t index, Disposition disposition)); | 24 MOCK_METHOD2(OnServiceChosen, void(const GURL& url, Disposition disposition)); |
25 MOCK_METHOD1(OnInlineDispositionWebContentsCreated, | 25 MOCK_METHOD1(OnInlineDispositionWebContentsCreated, |
26 void(content::WebContents* web_contents)); | 26 void(content::WebContents* web_contents)); |
27 MOCK_METHOD0(OnCancelled, void()); | 27 MOCK_METHOD0(OnCancelled, void()); |
28 MOCK_METHOD0(OnClosing, void()); | 28 MOCK_METHOD0(OnClosing, void()); |
29 }; | 29 }; |
30 | 30 |
31 } // namespace | 31 } // namespace |
32 | 32 |
33 class WebIntentPickerSheetControllerTest | 33 class WebIntentPickerSheetControllerTest |
34 : public TabContentsWrapperTestHarness { | 34 : public TabContentsWrapperTestHarness { |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 | 160 |
161 EXPECT_CALL(delegate_, OnCancelled()); | 161 EXPECT_CALL(delegate_, OnCancelled()); |
162 EXPECT_CALL(delegate_, OnClosing()); | 162 EXPECT_CALL(delegate_, OnClosing()); |
163 picker_->Close(); | 163 picker_->Close(); |
164 | 164 |
165 ignore_result(picker_.release()); // Closing |picker_| will destruct it. | 165 ignore_result(picker_.release()); // Closing |picker_| will destruct it. |
166 } | 166 } |
167 | 167 |
168 TEST_F(WebIntentPickerSheetControllerTest, DontCancelAfterServiceInvokation) { | 168 TEST_F(WebIntentPickerSheetControllerTest, DontCancelAfterServiceInvokation) { |
169 CreateBubble(); | 169 CreateBubble(); |
170 model_.AddInstalledService(string16(), GURL(), | 170 GURL url; |
| 171 model_.AddInstalledService(string16(), url, |
171 WebIntentPickerModel::DISPOSITION_WINDOW); | 172 WebIntentPickerModel::DISPOSITION_WINDOW); |
172 | 173 |
173 EXPECT_CALL(delegate_, OnServiceChosen( | 174 EXPECT_CALL(delegate_, OnServiceChosen( |
174 0, WebIntentPickerModel::DISPOSITION_WINDOW)); | 175 url, WebIntentPickerModel::DISPOSITION_WINDOW)); |
175 EXPECT_CALL(delegate_, OnCancelled()).Times(0); | 176 EXPECT_CALL(delegate_, OnCancelled()).Times(0); |
176 EXPECT_CALL(delegate_, OnClosing()); | 177 EXPECT_CALL(delegate_, OnClosing()); |
177 | 178 |
178 picker_->OnServiceChosen(0); | 179 picker_->OnServiceChosen(0); |
179 picker_->Close(); | 180 picker_->Close(); |
180 | 181 |
181 ignore_result(picker_.release()); // Closing |picker_| will destruct it. | 182 ignore_result(picker_.release()); // Closing |picker_| will destruct it. |
182 } | 183 } |
OLD | NEW |