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 <algorithm> | 5 #include <algorithm> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
185 | 185 |
186 virtual void SetUpOnMainThread() OVERRIDE { | 186 virtual void SetUpOnMainThread() OVERRIDE { |
187 // The FakeURLFetcherFactory will return a NULL URLFetcher if a request is | 187 // The FakeURLFetcherFactory will return a NULL URLFetcher if a request is |
188 // created for a URL it doesn't know and there is no default factory. | 188 // created for a URL it doesn't know and there is no default factory. |
189 // Instead, use this dummy factory to infinitely delay the request. | 189 // Instead, use this dummy factory to infinitely delay the request. |
190 default_url_fetcher_factory_.reset(new DummyURLFetcherFactory); | 190 default_url_fetcher_factory_.reset(new DummyURLFetcherFactory); |
191 fake_url_fetcher_factory_.reset( | 191 fake_url_fetcher_factory_.reset( |
192 new FakeURLFetcherFactory(default_url_fetcher_factory_.get())); | 192 new FakeURLFetcherFactory(default_url_fetcher_factory_.get())); |
193 | 193 |
194 web_data_service_ = | 194 web_data_service_ = |
195 browser()->profile()->GetWebDataService(Profile::EXPLICIT_ACCESS); | 195 GetBrowser()->profile()->GetWebDataService(Profile::EXPLICIT_ACCESS); |
196 favicon_service_ = | 196 favicon_service_ = |
197 browser()->profile()->GetFaviconService(Profile::EXPLICIT_ACCESS); | 197 GetBrowser()->profile()->GetFaviconService(Profile::EXPLICIT_ACCESS); |
198 controller_ = browser()-> | 198 controller_ = GetBrowser()-> |
199 GetSelectedTabContentsWrapper()->web_intent_picker_controller(); | 199 GetSelectedTabContentsWrapper()->web_intent_picker_controller(); |
200 | 200 |
201 controller_->set_picker(&picker_); | 201 controller_->set_picker(&picker_); |
202 controller_->set_model_observer(&picker_); | 202 controller_->set_model_observer(&picker_); |
203 | 203 |
204 CreateFakeIcon(); | 204 CreateFakeIcon(); |
205 } | 205 } |
206 | 206 |
207 virtual Browser* GetBrowser() { return browser(); } | |
208 | |
207 void AddWebIntentService(const string16& action, const GURL& service_url) { | 209 void AddWebIntentService(const string16& action, const GURL& service_url) { |
208 webkit_glue::WebIntentServiceData service; | 210 webkit_glue::WebIntentServiceData service; |
209 service.action = action; | 211 service.action = action; |
210 service.type = kType; | 212 service.type = kType; |
211 service.service_url = service_url; | 213 service.service_url = service_url; |
212 web_data_service_->AddWebIntentService(service); | 214 web_data_service_->AddWebIntentService(service); |
213 } | 215 } |
214 | 216 |
215 void AddCWSExtensionServiceEmpty(const string16& action) { | 217 void AddCWSExtensionServiceEmpty(const string16& action) { |
216 GURL cws_query_url = CWSIntentsRegistry::BuildQueryURL(action, kType); | 218 GURL cws_query_url = CWSIntentsRegistry::BuildQueryURL(action, kType); |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
349 ASSERT_EQ(3, browser()->tab_count()); | 351 ASSERT_EQ(3, browser()->tab_count()); |
350 EXPECT_EQ(GURL(kServiceURL1), | 352 EXPECT_EQ(GURL(kServiceURL1), |
351 browser()->GetSelectedWebContents()->GetURL()); | 353 browser()->GetSelectedWebContents()->GetURL()); |
352 | 354 |
353 EXPECT_TRUE(dispatcher.dispatched_); | 355 EXPECT_TRUE(dispatcher.dispatched_); |
354 | 356 |
355 OnSendReturnMessage(webkit_glue::WEB_INTENT_REPLY_SUCCESS); | 357 OnSendReturnMessage(webkit_glue::WEB_INTENT_REPLY_SUCCESS); |
356 ASSERT_EQ(2, browser()->tab_count()); | 358 ASSERT_EQ(2, browser()->tab_count()); |
357 EXPECT_EQ(original, browser()->GetSelectedWebContents()->GetURL()); | 359 EXPECT_EQ(original, browser()->GetSelectedWebContents()->GetURL()); |
358 } | 360 } |
361 | |
362 class WebIntentPickerControllerIncognitoBrowserTest : | |
363 public WebIntentPickerControllerBrowserTest { | |
364 public: | |
365 WebIntentPickerControllerIncognitoBrowserTest() {} | |
366 | |
367 virtual void SetUpOnMainThread() OVERRIDE { | |
groby-ooo-7-16
2012/03/22 00:20:24
Can we just have a WebIntentPickerControllerBrowse
binji
2012/03/22 00:38:40
I can't change the signature of SetUpOnMainThread,
| |
368 incognito_browser_ = CreateIncognitoBrowser(); | |
369 WebIntentPickerControllerBrowserTest::SetUpOnMainThread(); | |
370 } | |
371 | |
372 virtual Browser* GetBrowser() OVERRIDE { return incognito_browser_; } | |
373 | |
374 private: | |
375 Browser* incognito_browser_; | |
376 }; | |
377 | |
378 IN_PROC_BROWSER_TEST_F(WebIntentPickerControllerIncognitoBrowserTest, | |
379 ShowDialogShouldntCrash) { | |
380 controller_->ShowDialog(GetBrowser(), kAction1, kType); | |
381 // This should do nothing for now. | |
groby-ooo-7-16
2012/03/22 00:20:24
Does this test even work? It seems we never call t
binji
2012/03/22 00:38:40
The crash is in the picker controller, not the pic
| |
382 } | |
OLD | NEW |