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

Side by Side Diff: chrome/browser/autocomplete/autocomplete_provider_unittest.cc

Issue 12218104: Fix memory leak in AutocompleteProviderTest::GetDestinationURL unit test. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 7 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) 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 "chrome/browser/autocomplete/autocomplete_provider.h" 5 #include "chrome/browser/autocomplete/autocomplete_provider.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/string16.h" 10 #include "base/string16.h"
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 kResultsPerProvider * 2, 249 kResultsPerProvider * 2,
250 same_destinations ? ASCIIToUTF16("http://a") : ASCIIToUTF16("http://b"), 250 same_destinations ? ASCIIToUTF16("http://a") : ASCIIToUTF16("http://b"),
251 &profile_, 251 &profile_,
252 string16()); 252 string16());
253 provider2->AddRef(); 253 provider2->AddRef();
254 providers.push_back(provider2); 254 providers.push_back(provider2);
255 255
256 // Reset the controller to contain our new providers. 256 // Reset the controller to contain our new providers.
257 controller_.reset( 257 controller_.reset(
258 new AutocompleteController(&profile_, NULL, 258 new AutocompleteController(&profile_, NULL,
259 AutocompleteProvider::TYPE_SEARCH)); 259 0));
260 controller_->providers_.swap(providers); 260 controller_->providers_.swap(providers);
Bart N. 2013/02/12 00:30:34 I know it's not your fault, but the existing code
H Fung 2013/02/12 01:01:06 Done.
261 provider1->set_listener(controller_.get()); 261 provider1->set_listener(controller_.get());
262 provider2->set_listener(controller_.get()); 262 provider2->set_listener(controller_.get());
263 263
264 // The providers don't complete synchronously, so listen for "result updated" 264 // The providers don't complete synchronously, so listen for "result updated"
265 // notifications. 265 // notifications.
266 registrar_.Add(this, 266 registrar_.Add(this,
267 chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY, 267 chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY,
268 content::Source<AutocompleteController>(controller_.get())); 268 content::Source<AutocompleteController>(controller_.get()));
269 269
270 if (provider1_ptr) 270 if (provider1_ptr)
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.5.57j58j5l2j0l3j59" }, 552 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.5.57j58j5l2j0l3j59" },
553 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.6.57j58j5l2j0l3j59" }, 553 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.6.57j58j5l2j0l3j59" },
554 { AutocompleteMatch::SEARCH_HISTORY, "chrome.7.57j58j5l2j0l3j59" }, 554 { AutocompleteMatch::SEARCH_HISTORY, "chrome.7.57j58j5l2j0l3j59" },
555 }; 555 };
556 SCOPED_TRACE("Multiple matches"); 556 SCOPED_TRACE("Multiple matches");
557 RunAssistedQueryStatsTest(test_data, ARRAYSIZE_UNSAFE(test_data)); 557 RunAssistedQueryStatsTest(test_data, ARRAYSIZE_UNSAFE(test_data));
558 } 558 }
559 } 559 }
560 560
561 TEST_F(AutocompleteProviderTest, GetDestinationURL) { 561 TEST_F(AutocompleteProviderTest, GetDestinationURL) {
562 ResetControllerWithTestProviders(false, NULL, NULL); 562 ResetControllerWithKeywordAndSearchProviders();
563 563
564 // For the destination URL to have aqs parameters for query formulation time 564 // For the destination URL to have aqs parameters for query formulation time
565 // and the field trial triggered bit, many conditions need to be satisfied. 565 // and the field trial triggered bit, many conditions need to be satisfied.
566 AutocompleteMatch match(NULL, 1100, false, 566 AutocompleteMatch match(NULL, 1100, false,
567 AutocompleteMatch::SEARCH_SUGGEST); 567 AutocompleteMatch::SEARCH_SUGGEST);
568 GURL url = controller_-> 568 GURL url = controller_->
569 GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456)); 569 GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456));
570 EXPECT_TRUE(url.path().empty()); 570 EXPECT_TRUE(url.path().empty());
571 571
572 // The protocol needs to be https. 572 // The protocol needs to be https.
(...skipping 17 matching lines...) Expand all
590 EXPECT_TRUE(url.path().empty()); 590 EXPECT_TRUE(url.path().empty());
591 591
592 // assisted_query_stats needs to have been previously set. 592 // assisted_query_stats needs to have been previously set.
593 match.search_terms_args->assisted_query_stats = "chrome.0.57j58j5l2j0l3j59"; 593 match.search_terms_args->assisted_query_stats = "chrome.0.57j58j5l2j0l3j59";
594 url = controller_->GetDestinationURL(match, 594 url = controller_->GetDestinationURL(match,
595 base::TimeDelta::FromMilliseconds(2456)); 595 base::TimeDelta::FromMilliseconds(2456));
596 EXPECT_EQ("//aqs=chrome.0.57j58j5l2j0l3j59.2456j0&", url.path()); 596 EXPECT_EQ("//aqs=chrome.0.57j58j5l2j0l3j59.2456j0&", url.path());
597 597
598 // Test field trial triggered bit set. 598 // Test field trial triggered bit set.
599 controller_->search_provider_->field_trial_triggered_in_session_ = true; 599 controller_->search_provider_->field_trial_triggered_in_session_ = true;
600 EXPECT_TRUE(controller_->search_provider_->
601 field_trial_triggered_in_session());
600 url = controller_->GetDestinationURL(match, 602 url = controller_->GetDestinationURL(match,
601 base::TimeDelta::FromMilliseconds(2456)); 603 base::TimeDelta::FromMilliseconds(2456));
602 EXPECT_EQ("//aqs=chrome.0.57j58j5l2j0l3j59.2456j1&", url.path()); 604 EXPECT_EQ("//aqs=chrome.0.57j58j5l2j0l3j59.2456j1&", url.path());
603 } 605 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/autocomplete_controller.cc ('k') | tools/heapcheck/suppressions.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698