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

Side by Side Diff: chrome/browser/ui/cocoa/web_intent_sheet_controller_browsertest.mm

Issue 10534093: TabContentsWrapper -> TabContents, part 37. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 months 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/cocoa/web_intent_sheet_controller.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/test/base/in_process_browser_test.h" 6 #include "chrome/test/base/in_process_browser_test.h"
7 #include "chrome/browser/ui/browser.h" 7 #include "chrome/browser/ui/browser.h"
8 #include "chrome/browser/ui/cocoa/web_intent_picker_cocoa.h" 8 #include "chrome/browser/ui/cocoa/web_intent_picker_cocoa.h"
9 #import "chrome/browser/ui/cocoa/web_intent_sheet_controller.h" 9 #import "chrome/browser/ui/cocoa/web_intent_sheet_controller.h"
10 #include "chrome/browser/ui/intents/web_intent_picker_delegate.h" 10 #include "chrome/browser/ui/intents/web_intent_picker_delegate.h"
(...skipping 11 matching lines...) Expand all
22 MOCK_METHOD1(OnExtensionInstallRequested, void(const std::string& id)); 22 MOCK_METHOD1(OnExtensionInstallRequested, void(const std::string& id));
23 MOCK_METHOD1(OnExtensionLinkClicked, void(const std::string& id)); 23 MOCK_METHOD1(OnExtensionLinkClicked, void(const std::string& id));
24 MOCK_METHOD0(OnSuggestionsLinkClicked, void ()); 24 MOCK_METHOD0(OnSuggestionsLinkClicked, void ());
25 MOCK_METHOD0(OnPickerClosed, void()); 25 MOCK_METHOD0(OnPickerClosed, void());
26 MOCK_METHOD0(OnChooseAnotherService, void()); 26 MOCK_METHOD0(OnChooseAnotherService, void());
27 MOCK_METHOD0(OnClosing, void()); 27 MOCK_METHOD0(OnClosing, void());
28 }; 28 };
29 29
30 class WebIntentSheetControllerBrowserTest : public InProcessBrowserTest { 30 class WebIntentSheetControllerBrowserTest : public InProcessBrowserTest {
31 public: 31 public:
32 void CreateBubble(TabContentsWrapper* wrapper); 32 void CreateBubble(TabContents* tab_contents);
33 void CreatePicker(); 33 void CreatePicker();
34 34
35 WebIntentPickerSheetController* controller_; // Weak, owns self. 35 WebIntentPickerSheetController* controller_; // Weak, owns self.
36 NSWindow* window_; // Weak, owned by controller. 36 NSWindow* window_; // Weak, owned by controller.
37 scoped_ptr<WebIntentPickerCocoa> picker_; 37 scoped_ptr<WebIntentPickerCocoa> picker_;
38 MockIntentPickerDelegate delegate_; 38 MockIntentPickerDelegate delegate_;
39 WebIntentPickerModel model_; // The model used by the picker 39 WebIntentPickerModel model_; // The model used by the picker
40 }; 40 };
41 41
42 void WebIntentSheetControllerBrowserTest::CreateBubble( 42 void WebIntentSheetControllerBrowserTest::CreateBubble(
43 TabContentsWrapper* wrapper) { 43 TabContents* tab_contents) {
44 picker_.reset(new WebIntentPickerCocoa(wrapper, &delegate_, &model_)); 44 picker_.reset(new WebIntentPickerCocoa(tab_contents, &delegate_, &model_));
45 45
46 controller_ = 46 controller_ =
47 [[WebIntentPickerSheetController alloc] initWithPicker:picker_.get()]; 47 [[WebIntentPickerSheetController alloc] initWithPicker:picker_.get()];
48 window_ = [controller_ window]; 48 window_ = [controller_ window];
49 [controller_ showWindow:nil]; 49 [controller_ showWindow:nil];
50 } 50 }
51 51
52 void WebIntentSheetControllerBrowserTest::CreatePicker() { 52 void WebIntentSheetControllerBrowserTest::CreatePicker() {
53 picker_.reset(new WebIntentPickerCocoa()); 53 picker_.reset(new WebIntentPickerCocoa());
54 picker_->delegate_ = &delegate_; 54 picker_->delegate_ = &delegate_;
55 picker_->model_ = &model_; 55 picker_->model_ = &model_;
56 window_ = nil; 56 window_ = nil;
57 controller_ = nil; 57 controller_ = nil;
58 } 58 }
59 59
60 IN_PROC_BROWSER_TEST_F(WebIntentSheetControllerBrowserTest, CloseWillClose) { 60 IN_PROC_BROWSER_TEST_F(WebIntentSheetControllerBrowserTest, CloseWillClose) {
61 CreateBubble(browser()->GetSelectedTabContentsWrapper()); 61 CreateBubble(browser()->GetActiveTabContents());
62 62
63 EXPECT_CALL(delegate_, OnPickerClosed()).Times(0); 63 EXPECT_CALL(delegate_, OnPickerClosed()).Times(0);
64 EXPECT_CALL(delegate_, OnClosing()); 64 EXPECT_CALL(delegate_, OnClosing());
65 picker_->Close(); 65 picker_->Close();
66 66
67 ignore_result(picker_.release()); // Closing |picker_| will destruct it. 67 ignore_result(picker_.release()); // Closing |picker_| will destruct it.
68 } 68 }
69 69
70 IN_PROC_BROWSER_TEST_F(WebIntentSheetControllerBrowserTest, 70 IN_PROC_BROWSER_TEST_F(WebIntentSheetControllerBrowserTest,
71 DontCancelAfterServiceInvokation) { 71 DontCancelAfterServiceInvokation) {
72 CreateBubble(browser()->GetSelectedTabContentsWrapper()); 72 CreateBubble(browser()->GetActiveTabContents());
73 73
74 GURL url; 74 GURL url;
75 model_.AddInstalledService(string16(), url, 75 model_.AddInstalledService(string16(), url,
76 WebIntentPickerModel::DISPOSITION_WINDOW); 76 WebIntentPickerModel::DISPOSITION_WINDOW);
77 77
78 EXPECT_CALL(delegate_, OnServiceChosen( 78 EXPECT_CALL(delegate_, OnServiceChosen(
79 url, WebIntentPickerModel::DISPOSITION_WINDOW)); 79 url, WebIntentPickerModel::DISPOSITION_WINDOW));
80 EXPECT_CALL(delegate_, OnPickerClosed()).Times(0); 80 EXPECT_CALL(delegate_, OnPickerClosed()).Times(0);
81 EXPECT_CALL(delegate_, OnClosing()); 81 EXPECT_CALL(delegate_, OnClosing());
82 82
83 picker_->OnServiceChosen(0); 83 picker_->OnServiceChosen(0);
84 picker_->Close(); 84 picker_->Close();
85 85
86 ignore_result(picker_.release()); // Closing |picker_| will destruct it. 86 ignore_result(picker_.release()); // Closing |picker_| will destruct it.
87 } 87 }
88 88
89 IN_PROC_BROWSER_TEST_F(WebIntentSheetControllerBrowserTest, 89 IN_PROC_BROWSER_TEST_F(WebIntentSheetControllerBrowserTest,
90 OnCancelledWillSignalClose) { 90 OnCancelledWillSignalClose) {
91 CreatePicker(); 91 CreatePicker();
92 EXPECT_CALL(delegate_, OnPickerClosed()); 92 EXPECT_CALL(delegate_, OnPickerClosed());
93 EXPECT_CALL(delegate_, OnClosing()); 93 EXPECT_CALL(delegate_, OnClosing());
94 picker_->OnCancelled(); 94 picker_->OnCancelled();
95 95
96 ignore_result(picker_.release()); // Closing |picker_| will destruct it. 96 ignore_result(picker_.release()); // Closing |picker_| will destruct it.
97 } 97 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/web_intent_sheet_controller.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698