| OLD | NEW |
| 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/callback.h" | 5 #include "base/callback.h" |
| 6 #include "base/memory/ref_counted.h" | 6 #include "base/memory/ref_counted.h" |
| 7 #include "base/memory/scoped_vector.h" | 7 #include "base/memory/scoped_vector.h" |
| 8 #include "base/string_split.h" | 8 #include "base/string_split.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "chrome/test/testing_pref_service.h" | 22 #include "chrome/test/testing_pref_service.h" |
| 23 #include "chrome/test/testing_profile.h" | 23 #include "chrome/test/testing_profile.h" |
| 24 #include "content/browser/browser_thread.h" | 24 #include "content/browser/browser_thread.h" |
| 25 #include "content/common/notification_details.h" | 25 #include "content/common/notification_details.h" |
| 26 #include "content/common/notification_source.h" | 26 #include "content/common/notification_source.h" |
| 27 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
| 28 | 28 |
| 29 using base::Time; | 29 using base::Time; |
| 30 using base::TimeDelta; | 30 using base::TimeDelta; |
| 31 | 31 |
| 32 #if defined(OS_LINUX) | |
| 33 // Timed out on Chromium Linux. http://crbug.com/53607 | |
| 34 #define MAYBE_Load DISABLED_Load | |
| 35 #else | |
| 36 #define MAYBE_Load Load | |
| 37 #endif | |
| 38 | |
| 39 // Test the GenerateSearchURL on a thread or the main thread. | 32 // Test the GenerateSearchURL on a thread or the main thread. |
| 40 class TestGenerateSearchURL | 33 class TestGenerateSearchURL |
| 41 : public base::RefCountedThreadSafe<TestGenerateSearchURL> { | 34 : public base::RefCountedThreadSafe<TestGenerateSearchURL> { |
| 42 public: | 35 public: |
| 43 explicit TestGenerateSearchURL(SearchTermsData* search_terms_data) | 36 explicit TestGenerateSearchURL(SearchTermsData* search_terms_data) |
| 44 : search_terms_data_(search_terms_data), | 37 : search_terms_data_(search_terms_data), |
| 45 passed_(false) { | 38 passed_(false) { |
| 46 } | 39 } |
| 47 | 40 |
| 48 // Run the test cases for GenerateSearchURL. | 41 // Run the test cases for GenerateSearchURL. |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 // Wait for any saves to finish. | 364 // Wait for any saves to finish. |
| 372 BlockTillServiceProcessesRequests(); | 365 BlockTillServiceProcessesRequests(); |
| 373 | 366 |
| 374 // Reload the model to verify that change was saved correctly. | 367 // Reload the model to verify that change was saved correctly. |
| 375 ResetModel(true); | 368 ResetModel(true); |
| 376 keyword_url = model()->GetTemplateURLForKeyword(ASCIIToUTF16("unittest")); | 369 keyword_url = model()->GetTemplateURLForKeyword(ASCIIToUTF16("unittest")); |
| 377 ASSERT_TRUE(keyword_url != NULL); | 370 ASSERT_TRUE(keyword_url != NULL); |
| 378 ASSERT_EQ(prepopulated_url, keyword_url->url()->DisplayURL()); | 371 ASSERT_EQ(prepopulated_url, keyword_url->url()->DisplayURL()); |
| 379 } | 372 } |
| 380 | 373 |
| 381 TEST_F(TemplateURLServiceTest, MAYBE_Load) { | 374 TEST_F(TemplateURLServiceTest, Load) { |
| 382 VerifyLoad(); | 375 VerifyLoad(); |
| 383 } | 376 } |
| 384 | 377 |
| 385 TEST_F(TemplateURLServiceTest, AddUpdateRemove) { | 378 TEST_F(TemplateURLServiceTest, AddUpdateRemove) { |
| 386 // Add a new TemplateURL. | 379 // Add a new TemplateURL. |
| 387 VerifyLoad(); | 380 VerifyLoad(); |
| 388 const size_t initial_count = model()->GetTemplateURLs().size(); | 381 const size_t initial_count = model()->GetTemplateURLs().size(); |
| 389 | 382 |
| 390 TemplateURL* t_url = new TemplateURL(); | 383 TemplateURL* t_url = new TemplateURL(); |
| 391 t_url->SetURL("http://www.google.com/foo/bar", 0, 0); | 384 t_url->SetURL("http://www.google.com/foo/bar", 0, 0); |
| (...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1188 kEncodings, ""); | 1181 kEncodings, ""); |
| 1189 VerifyObserverFired(); | 1182 VerifyObserverFired(); |
| 1190 EXPECT_TRUE(model()->is_default_search_managed()); | 1183 EXPECT_TRUE(model()->is_default_search_managed()); |
| 1191 EXPECT_EQ(2 + initial_count, model()->GetTemplateURLs().size()); | 1184 EXPECT_EQ(2 + initial_count, model()->GetTemplateURLs().size()); |
| 1192 | 1185 |
| 1193 // Verify that the default manager we are getting is the managed one. | 1186 // Verify that the default manager we are getting is the managed one. |
| 1194 actual_managed_default = model()->GetDefaultSearchProvider(); | 1187 actual_managed_default = model()->GetDefaultSearchProvider(); |
| 1195 ExpectSimilar(actual_managed_default, expected_managed_default1.get()); | 1188 ExpectSimilar(actual_managed_default, expected_managed_default1.get()); |
| 1196 EXPECT_EQ(actual_managed_default->show_in_default_list(), true); | 1189 EXPECT_EQ(actual_managed_default->show_in_default_list(), true); |
| 1197 } | 1190 } |
| OLD | NEW |