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

Side by Side Diff: chrome/browser/ui/webui/browsing_history_handler_unittest.cc

Issue 2511993002: Migrate md history test code to ScopedFeatureList. (Closed)
Patch Set: rebase Created 4 years, 1 month 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/ui/webui/browsing_history_handler.h" 5 #include "chrome/browser/ui/webui/browsing_history_handler.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <memory> 8 #include <memory>
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
15 #include "base/test/scoped_feature_list.h"
15 #include "base/test/simple_test_clock.h" 16 #include "base/test/simple_test_clock.h"
16 #include "base/values.h" 17 #include "base/values.h"
17 #include "chrome/browser/history/browsing_history_service.h" 18 #include "chrome/browser/history/browsing_history_service.h"
18 #include "chrome/browser/history/web_history_service_factory.h" 19 #include "chrome/browser/history/web_history_service_factory.h"
19 #include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" 20 #include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h"
20 #include "chrome/browser/signin/fake_signin_manager_builder.h" 21 #include "chrome/browser/signin/fake_signin_manager_builder.h"
21 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 22 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
22 #include "chrome/browser/signin/signin_manager_factory.h" 23 #include "chrome/browser/signin/signin_manager_factory.h"
23 #include "chrome/browser/sync/profile_sync_service_factory.h" 24 #include "chrome/browser/sync/profile_sync_service_factory.h"
24 #include "chrome/browser/sync/profile_sync_test_util.h" 25 #include "chrome/browser/sync/profile_sync_test_util.h"
26 #include "chrome/common/chrome_features.h"
25 #include "chrome/test/base/testing_profile.h" 27 #include "chrome/test/base/testing_profile.h"
26 #include "components/browser_sync/test_profile_sync_service.h" 28 #include "components/browser_sync/test_profile_sync_service.h"
27 #include "components/history/core/test/fake_web_history_service.h" 29 #include "components/history/core/test/fake_web_history_service.h"
28 #include "components/signin/core/browser/fake_profile_oauth2_token_service.h" 30 #include "components/signin/core/browser/fake_profile_oauth2_token_service.h"
29 #include "components/signin/core/browser/fake_signin_manager.h" 31 #include "components/signin/core/browser/fake_signin_manager.h"
30 #include "components/sync/base/model_type.h" 32 #include "components/sync/base/model_type.h"
31 #include "content/public/browser/browser_thread.h" 33 #include "content/public/browser/browser_thread.h"
32 #include "content/public/browser/web_contents.h" 34 #include "content/public/browser/web_contents.h"
33 #include "content/public/test/test_browser_thread_bundle.h" 35 #include "content/public/test/test_browser_thread_bundle.h"
34 #include "content/public/test/test_web_ui.h" 36 #include "content/public/test/test_web_ui.h"
35 #include "net/http/http_status_code.h" 37 #include "net/http/http_status_code.h"
36 #include "testing/gtest/include/gtest/gtest.h" 38 #include "testing/gtest/include/gtest/gtest.h"
37 #include "url/gurl.h" 39 #include "url/gurl.h"
38 40
39 #if !defined(OS_ANDROID)
40 #include "chrome/browser/ui/webui/md_history_ui.h"
41 #endif
42
43 namespace { 41 namespace {
44 42
45 // Duplicates on the same day in the local timezone are removed, so set a 43 // Duplicates on the same day in the local timezone are removed, so set a
46 // baseline time in local time. 44 // baseline time in local time.
47 const base::Time baseline_time = base::Time::UnixEpoch().LocalMidnight(); 45 const base::Time baseline_time = base::Time::UnixEpoch().LocalMidnight();
48 46
49 base::Time PretendNow() { 47 base::Time PretendNow() {
50 base::Time::Exploded exploded_reference_time; 48 base::Time::Exploded exploded_reference_time;
51 exploded_reference_time.year = 2015; 49 exploded_reference_time.year = 2015;
52 exploded_reference_time.month = 1; 50 exploded_reference_time.month = 1;
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 web_history_service()->ExpireHistoryBetween(std::set<GURL>(), base::Time(), 297 web_history_service()->ExpireHistoryBetween(std::set<GURL>(), base::Time(),
300 base::Time::Max(), callback); 298 base::Time::Max(), callback);
301 299
302 // No additional WebUI calls were made. 300 // No additional WebUI calls were made.
303 EXPECT_EQ(3U, web_ui()->call_data().size()); 301 EXPECT_EQ(3U, web_ui()->call_data().size());
304 } 302 }
305 } 303 }
306 304
307 #if !defined(OS_ANDROID) 305 #if !defined(OS_ANDROID)
308 TEST_F(BrowsingHistoryHandlerTest, MdTruncatesTitles) { 306 TEST_F(BrowsingHistoryHandlerTest, MdTruncatesTitles) {
309 MdHistoryUI::SetEnabledForTesting(true); 307 base::test::ScopedFeatureList scoped_feature_list;
308 scoped_feature_list.InitAndEnableFeature(features::kMaterialDesignHistory);
310 309
311 history::URLResult long_result( 310 history::URLResult long_result(
312 GURL("http://looooooooooooooooooooooooooooooooooooooooooooooooooooooooooo" 311 GURL("http://looooooooooooooooooooooooooooooooooooooooooooooooooooooooooo"
313 "oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo" 312 "oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo"
314 "oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo" 313 "oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo"
315 "oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo" 314 "oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo"
316 "oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo" 315 "oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo"
317 "oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo" 316 "oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo"
318 "ngurlislong.com"), base::Time()); 317 "ngurlislong.com"), base::Time());
319 ASSERT_GT(long_result.url().spec().size(), 300u); 318 ASSERT_GT(long_result.url().spec().size(), 300u);
(...skipping 15 matching lines...) Expand all
335 const base::DictionaryValue* first_entry; 334 const base::DictionaryValue* first_entry;
336 ASSERT_TRUE(arg2->GetDictionary(0, &first_entry)); 335 ASSERT_TRUE(arg2->GetDictionary(0, &first_entry));
337 336
338 base::string16 title; 337 base::string16 title;
339 ASSERT_TRUE(first_entry->GetString("title", &title)); 338 ASSERT_TRUE(first_entry->GetString("title", &title));
340 339
341 ASSERT_EQ(0u, title.find(base::ASCIIToUTF16("http://loooo"))); 340 ASSERT_EQ(0u, title.find(base::ASCIIToUTF16("http://loooo")));
342 EXPECT_EQ(300u, title.size()); 341 EXPECT_EQ(300u, title.size());
343 } 342 }
344 #endif 343 #endif
OLDNEW
« no previous file with comments | « chrome/browser/ui/find_bar/find_bar_host_browsertest.cc ('k') | chrome/browser/ui/webui/log_web_ui_url_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698