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

Side by Side Diff: chrome/browser/ui/intents/web_intent_picker_controller_browsertest.cc

Issue 8666013: Add a public content/ interface for intents. Use it. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: For try servers. Created 9 years 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
OLDNEW
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 #include "base/bind.h" 5 #include "base/bind.h"
6 #include "base/callback.h" 6 #include "base/callback.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/favicon/favicon_service.h" 9 #include "chrome/browser/favicon/favicon_service.h"
10 #include "chrome/browser/intents/web_intents_registry.h" 10 #include "chrome/browser/intents/web_intents_registry.h"
11 #include "chrome/browser/intents/web_intents_registry_factory.h" 11 #include "chrome/browser/intents/web_intents_registry_factory.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/ui/browser.h" 13 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/intents/web_intent_picker.h" 14 #include "chrome/browser/ui/intents/web_intent_picker.h"
15 #include "chrome/browser/ui/intents/web_intent_picker_controller.h" 15 #include "chrome/browser/ui/intents/web_intent_picker_controller.h"
16 #include "chrome/browser/ui/intents/web_intent_picker_factory.h" 16 #include "chrome/browser/ui/intents/web_intent_picker_factory.h"
17 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 17 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
18 #include "chrome/browser/webdata/web_data_service.h" 18 #include "chrome/browser/webdata/web_data_service.h"
19 #include "chrome/test/base/in_process_browser_test.h" 19 #include "chrome/test/base/in_process_browser_test.h"
20 #include "chrome/test/base/ui_test_utils.h" 20 #include "chrome/test/base/ui_test_utils.h"
21 #include "content/browser/tab_contents/tab_contents.h" 21 #include "content/browser/tab_contents/tab_contents.h"
22 #include "content/public/browser/intents_host.h"
22 #include "testing/gmock/include/gmock/gmock.h" 23 #include "testing/gmock/include/gmock/gmock.h"
23 #include "testing/gtest/include/gtest/gtest.h" 24 #include "testing/gtest/include/gtest/gtest.h"
24 #include "webkit/glue/web_intent_service_data.h" 25 #include "webkit/glue/web_intent_service_data.h"
25 26
26 using testing::_; 27 using testing::_;
27 using testing::DoAll; 28 using testing::DoAll;
28 using testing::Return; 29 using testing::Return;
29 using testing::SaveArg; 30 using testing::SaveArg;
30 31
31 namespace { 32 namespace {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 } 92 }
92 } 93 }
93 94
94 void Close() { 95 void Close() {
95 picker_ = NULL; 96 picker_ = NULL;
96 } 97 }
97 98
98 WebIntentPicker* picker_; 99 WebIntentPicker* picker_;
99 }; 100 };
100 101
102 class IntentsHostMock : public content::IntentsHost {
103 public:
104 explicit IntentsHostMock(const webkit_glue::WebIntentData& intent)
105 : intent_(intent),
106 dispatched_(false) {}
107
108 virtual const webkit_glue::WebIntentData& GetIntent() {
109 return intent_;
110 }
111
112 virtual void DispatchIntent(TabContents* tab_contents) {
113 dispatched_ = true;
114 }
115
116 virtual void SendReplyMessage(webkit_glue::WebIntentReplyType reply_type,
117 const string16& data) {
118 }
119
120 virtual void RegisterReplyNotification(const base::Closure&) {
121 }
122
123 webkit_glue::WebIntentData intent_;
124 bool dispatched_;
125 };
126
101 class WebIntentPickerControllerBrowserTest : public InProcessBrowserTest { 127 class WebIntentPickerControllerBrowserTest : public InProcessBrowserTest {
102 protected: 128 protected:
103 void AddWebIntentService(const string16& action, 129 void AddWebIntentService(const string16& action,
104 const GURL& service_url) { 130 const GURL& service_url) {
105 webkit_glue::WebIntentServiceData service; 131 webkit_glue::WebIntentServiceData service;
106 service.action = action; 132 service.action = action;
107 service.type = kType; 133 service.type = kType;
108 service.service_url = service_url; 134 service.service_url = service_url;
109 web_data_service_->AddWebIntentService(service); 135 web_data_service_->AddWebIntentService(service);
110 } 136 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 SetPickerFactory(controller, picker_factory_); 172 SetPickerFactory(controller, picker_factory_);
147 173
148 controller->ShowDialog(browser(), kAction1, kType); 174 controller->ShowDialog(browser(), kAction1, kType);
149 picker_.WaitFor(2, 2); 175 picker_.WaitFor(2, 2);
150 EXPECT_EQ(2, picker_.num_urls_); 176 EXPECT_EQ(2, picker_.num_urls_);
151 EXPECT_EQ(2, picker_.num_default_icons_); 177 EXPECT_EQ(2, picker_.num_default_icons_);
152 178
153 webkit_glue::WebIntentData intent; 179 webkit_glue::WebIntentData intent;
154 intent.action = ASCIIToUTF16("a"); 180 intent.action = ASCIIToUTF16("a");
155 intent.type = ASCIIToUTF16("b"); 181 intent.type = ASCIIToUTF16("b");
156 controller->SetIntent(1, intent, 1); 182 IntentsHostMock* host = new IntentsHostMock(intent);
183 controller->SetIntentsHost(host);
157 184
158 OnServiceChosen(controller, 1); 185 OnServiceChosen(controller, 1);
159 ASSERT_EQ(2, browser()->tab_count()); 186 ASSERT_EQ(2, browser()->tab_count());
160 EXPECT_EQ(GURL(kServiceURL2), 187 EXPECT_EQ(GURL(kServiceURL2),
161 browser()->GetSelectedTabContents()->GetURL()); 188 browser()->GetSelectedTabContents()->GetURL());
162 189
190 EXPECT_TRUE(host->dispatched_);
191
163 OnSendReturnMessage(controller); 192 OnSendReturnMessage(controller);
164 ASSERT_EQ(1, browser()->tab_count()); 193 ASSERT_EQ(1, browser()->tab_count());
165 } 194 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/intents/web_intent_picker_controller.cc ('k') | content/browser/intents/intent_injector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698