| 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 "base/callback_helpers.h" | 5 #include "base/callback_helpers.h" |
| 6 #include "base/files/file_util.h" | 6 #include "base/files/file_util.h" |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 } test_cases[] = { | 197 } test_cases[] = { |
| 198 { "Duplicate osdd url with autodetected provider.", osdd_file_name, | 198 { "Duplicate osdd url with autodetected provider.", osdd_file_name, |
| 199 keyword + ASCIIToUTF16("1"), | 199 keyword + ASCIIToUTF16("1"), |
| 200 TemplateURLFetcher::AUTODETECTED_PROVIDER }, | 200 TemplateURLFetcher::AUTODETECTED_PROVIDER }, |
| 201 { "Duplicate keyword with autodetected provider.", osdd_file_name + "1", | 201 { "Duplicate keyword with autodetected provider.", osdd_file_name + "1", |
| 202 keyword, TemplateURLFetcher::AUTODETECTED_PROVIDER }, | 202 keyword, TemplateURLFetcher::AUTODETECTED_PROVIDER }, |
| 203 { "Duplicate osdd url with explicit provider.", osdd_file_name, | 203 { "Duplicate osdd url with explicit provider.", osdd_file_name, |
| 204 base::string16(), TemplateURLFetcher::EXPLICIT_PROVIDER }, | 204 base::string16(), TemplateURLFetcher::EXPLICIT_PROVIDER }, |
| 205 }; | 205 }; |
| 206 | 206 |
| 207 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { | 207 for (size_t i = 0; i < arraysize(test_cases); ++i) { |
| 208 StartDownload(test_cases[i].keyword, test_cases[i].osdd_file_name, | 208 StartDownload(test_cases[i].keyword, test_cases[i].osdd_file_name, |
| 209 test_cases[i].provider_type, false); | 209 test_cases[i].provider_type, false); |
| 210 ASSERT_EQ(1, template_url_fetcher()->requests_count()) | 210 ASSERT_EQ(1, template_url_fetcher()->requests_count()) |
| 211 << test_cases[i].description; | 211 << test_cases[i].description; |
| 212 ASSERT_EQ(i + 1, static_cast<size_t>(callbacks_destroyed())); | 212 ASSERT_EQ(i + 1, static_cast<size_t>(callbacks_destroyed())); |
| 213 } | 213 } |
| 214 | 214 |
| 215 WaitForDownloadToFinish(); | 215 WaitForDownloadToFinish(); |
| 216 ASSERT_EQ(1 + ARRAYSIZE_UNSAFE(test_cases), | 216 ASSERT_EQ(1 + arraysize(test_cases), |
| 217 static_cast<size_t>(callbacks_destroyed())); | 217 static_cast<size_t>(callbacks_destroyed())); |
| 218 ASSERT_EQ(0, add_provider_called()); | 218 ASSERT_EQ(0, add_provider_called()); |
| 219 } | 219 } |
| 220 | 220 |
| 221 TEST_F(TemplateURLFetcherTest, BasicExplicitTest) { | 221 TEST_F(TemplateURLFetcherTest, BasicExplicitTest) { |
| 222 base::string16 keyword(ASCIIToUTF16("test")); | 222 base::string16 keyword(ASCIIToUTF16("test")); |
| 223 | 223 |
| 224 test_util()->ChangeModelToLoadState(); | 224 test_util()->ChangeModelToLoadState(); |
| 225 ASSERT_FALSE(test_util()->model()->GetTemplateURLForKeyword(keyword)); | 225 ASSERT_FALSE(test_util()->model()->GetTemplateURLForKeyword(keyword)); |
| 226 | 226 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 StartDownload(keyword, osdd_file_name, | 309 StartDownload(keyword, osdd_file_name, |
| 310 TemplateURLFetcher::EXPLICIT_PROVIDER, true); | 310 TemplateURLFetcher::EXPLICIT_PROVIDER, true); |
| 311 ASSERT_EQ(0, add_provider_called()); | 311 ASSERT_EQ(0, add_provider_called()); |
| 312 ASSERT_EQ(1, callbacks_destroyed()); | 312 ASSERT_EQ(1, callbacks_destroyed()); |
| 313 | 313 |
| 314 WaitForDownloadToFinish(); | 314 WaitForDownloadToFinish(); |
| 315 ASSERT_EQ(1, add_provider_called()); | 315 ASSERT_EQ(1, add_provider_called()); |
| 316 ASSERT_EQ(2, callbacks_destroyed()); | 316 ASSERT_EQ(2, callbacks_destroyed()); |
| 317 ASSERT_TRUE(last_callback_template_url()); | 317 ASSERT_TRUE(last_callback_template_url()); |
| 318 } | 318 } |
| OLD | NEW |