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

Side by Side Diff: chrome/browser/autofill/autofill_download_unittest.cc

Issue 6478005: GTTF: Use a fresh TestingBrowserProcess for each test, part #1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: make more tests use the new base class Created 9 years, 10 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
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 <list> 5 #include <list>
6 6
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "base/test/test_timeouts.h" 8 #include "base/test/test_timeouts.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/autofill/autofill_download.h" 10 #include "chrome/browser/autofill/autofill_download.h"
11 #include "chrome/browser/autofill/autofill_metrics.h" 11 #include "chrome/browser/autofill/autofill_metrics.h"
12 #include "chrome/common/net/test_url_fetcher_factory.h" 12 #include "chrome/common/net/test_url_fetcher_factory.h"
13 #include "chrome/test/testing_browser_process.h"
14 #include "chrome/test/testing_browser_process_test.h"
13 #include "chrome/test/testing_profile.h" 15 #include "chrome/test/testing_profile.h"
14 #include "net/url_request/url_request_status.h" 16 #include "net/url_request/url_request_status.h"
15 #include "testing/gmock/include/gmock/gmock.h" 17 #include "testing/gmock/include/gmock/gmock.h"
16 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h" 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h"
18 #include "webkit/glue/form_data.h" 20 #include "webkit/glue/form_data.h"
19 21
20 using webkit_glue::FormData; 22 using webkit_glue::FormData;
21 using WebKit::WebInputElement; 23 using WebKit::WebInputElement;
22 24
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 std::string response; 97 std::string response;
96 ResponseData() : type_of_response(REQUEST_QUERY_FAILED), error(0) { 98 ResponseData() : type_of_response(REQUEST_QUERY_FAILED), error(0) {
97 } 99 }
98 }; 100 };
99 std::list<AutoFillDownloadTestHelper::ResponseData> responses_; 101 std::list<AutoFillDownloadTestHelper::ResponseData> responses_;
100 102
101 TestingProfile profile; 103 TestingProfile profile;
102 AutoFillDownloadManager download_manager; 104 AutoFillDownloadManager download_manager;
103 }; 105 };
104 106
105 TEST(AutoFillDownloadTest, QueryAndUploadTest) { 107 typedef TestingBrowserProcessTest AutoFillDownloadTest;
108
109 TEST_F(AutoFillDownloadTest, QueryAndUploadTest) {
106 MessageLoopForUI message_loop; 110 MessageLoopForUI message_loop;
107 // Create and register factory. 111 // Create and register factory.
108 AutoFillDownloadTestHelper helper; 112 AutoFillDownloadTestHelper helper;
109 TestURLFetcherFactory factory; 113 TestURLFetcherFactory factory;
110 URLFetcher::set_factory(&factory); 114 URLFetcher::set_factory(&factory);
111 115
112 FormData form; 116 FormData form;
113 form.method = ASCIIToUTF16("post"); 117 form.method = ASCIIToUTF16("post");
114 form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("username"), 118 form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("username"),
115 ASCIIToUTF16("username"), 119 ASCIIToUTF16("username"),
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 // Upload requests should be ignored for the next 10 seconds. 338 // Upload requests should be ignored for the next 10 seconds.
335 EXPECT_FALSE(helper.download_manager.StartUploadRequest(*(form_structures[0]), 339 EXPECT_FALSE(helper.download_manager.StartUploadRequest(*(form_structures[0]),
336 true)); 340 true));
337 fetcher = factory.GetFetcherByID(5); 341 fetcher = factory.GetFetcherByID(5);
338 EXPECT_EQ(NULL, fetcher); 342 EXPECT_EQ(NULL, fetcher);
339 343
340 // Make sure consumer of URLFetcher does the right thing. 344 // Make sure consumer of URLFetcher does the right thing.
341 URLFetcher::set_factory(NULL); 345 URLFetcher::set_factory(NULL);
342 } 346 }
343 347
344 TEST(AutoFillDownloadTest, CacheQueryTest) { 348 TEST_F(AutoFillDownloadTest, CacheQueryTest) {
345 MessageLoopForUI message_loop; 349 MessageLoopForUI message_loop;
346 AutoFillDownloadTestHelper helper; 350 AutoFillDownloadTestHelper helper;
347 // Create and register factory. 351 // Create and register factory.
348 TestURLFetcherFactory factory; 352 TestURLFetcherFactory factory;
349 URLFetcher::set_factory(&factory); 353 URLFetcher::set_factory(&factory);
350 354
351 FormData form; 355 FormData form;
352 form.method = ASCIIToUTF16("post"); 356 form.method = ASCIIToUTF16("post");
353 form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("username"), 357 form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("username"),
354 ASCIIToUTF16("username"), 358 ASCIIToUTF16("username"),
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 net::URLRequestStatus(), 512 net::URLRequestStatus(),
509 200, ResponseCookies(), 513 200, ResponseCookies(),
510 std::string(responses[0])); 514 std::string(responses[0]));
511 ASSERT_EQ(static_cast<size_t>(1), helper.responses_.size()); 515 ASSERT_EQ(static_cast<size_t>(1), helper.responses_.size());
512 EXPECT_EQ(responses[0], helper.responses_.front().response); 516 EXPECT_EQ(responses[0], helper.responses_.front().response);
513 517
514 // Make sure consumer of URLFetcher does the right thing. 518 // Make sure consumer of URLFetcher does the right thing.
515 URLFetcher::set_factory(NULL); 519 URLFetcher::set_factory(NULL);
516 } 520 }
517 521
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698