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

Side by Side Diff: components/visitedlink/test/visitedlink_unittest.cc

Issue 1917673002: Convert //components/[u-z]* from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 7 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
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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <cstdio> 8 #include <cstdio>
9 #include <memory>
9 #include <string> 10 #include <string>
10 #include <vector> 11 #include <vector>
11 12
12 #include "base/files/file_util.h" 13 #include "base/files/file_util.h"
13 #include "base/location.h" 14 #include "base/location.h"
14 #include "base/macros.h" 15 #include "base/macros.h"
15 #include "base/memory/shared_memory.h" 16 #include "base/memory/shared_memory.h"
16 #include "base/process/process_handle.h" 17 #include "base/process/process_handle.h"
17 #include "base/run_loop.h" 18 #include "base/run_loop.h"
18 #include "base/single_thread_task_runner.h" 19 #include "base/single_thread_task_runner.h"
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 } 239 }
239 240
240 void TearDown() override { ClearDB(); } 241 void TearDown() override { ClearDB(); }
241 242
242 base::ScopedTempDir temp_dir_; 243 base::ScopedTempDir temp_dir_;
243 244
244 // Filenames for the services; 245 // Filenames for the services;
245 base::FilePath history_dir_; 246 base::FilePath history_dir_;
246 base::FilePath visited_file_; 247 base::FilePath visited_file_;
247 248
248 scoped_ptr<VisitedLinkMaster> master_; 249 std::unique_ptr<VisitedLinkMaster> master_;
249 TestVisitedLinkDelegate delegate_; 250 TestVisitedLinkDelegate delegate_;
250 content::TestBrowserThreadBundle thread_bundle_; 251 content::TestBrowserThreadBundle thread_bundle_;
251 }; 252 };
252 253
253 // This test creates and reads some databases to make sure the data is 254 // This test creates and reads some databases to make sure the data is
254 // preserved throughout those operations. 255 // preserved throughout those operations.
255 TEST_F(VisitedLinkTest, DatabaseIO) { 256 TEST_F(VisitedLinkTest, DatabaseIO) {
256 ASSERT_TRUE(InitVisited(0, true, true)); 257 ASSERT_TRUE(InitVisited(0, true, true));
257 258
258 for (int i = 0; i < g_test_count; i++) 259 for (int i = 0; i < g_test_count; i++)
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 682
682 protected: 683 protected:
683 void CreateVisitedLinkMaster(content::BrowserContext* browser_context) { 684 void CreateVisitedLinkMaster(content::BrowserContext* browser_context) {
684 master_.reset(new VisitedLinkMaster(browser_context, &delegate_, true)); 685 master_.reset(new VisitedLinkMaster(browser_context, &delegate_, true));
685 master_->Init(); 686 master_->Init();
686 } 687 }
687 688
688 VisitedLinkRenderProcessHostFactory vc_rph_factory_; 689 VisitedLinkRenderProcessHostFactory vc_rph_factory_;
689 690
690 TestVisitedLinkDelegate delegate_; 691 TestVisitedLinkDelegate delegate_;
691 scoped_ptr<VisitedLinkMaster> master_; 692 std::unique_ptr<VisitedLinkMaster> master_;
692 }; 693 };
693 694
694 TEST_F(VisitedLinkEventsTest, Coalescence) { 695 TEST_F(VisitedLinkEventsTest, Coalescence) {
695 // Waiting complete rebuild the table. 696 // Waiting complete rebuild the table.
696 content::RunAllBlockingPoolTasksUntilIdle(); 697 content::RunAllBlockingPoolTasksUntilIdle();
697 698
698 WaitForCoalescence(); 699 WaitForCoalescence();
699 700
700 // After rebuild table expect reset event. 701 // After rebuild table expect reset event.
701 EXPECT_EQ(1, context()->reset_event_count()); 702 EXPECT_EQ(1, context()->reset_event_count());
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 content::BrowserContext* CreateBrowserContext() override { 858 content::BrowserContext* CreateBrowserContext() override {
858 VisitCountingContext* context = new VisitCountingContext(); 859 VisitCountingContext* context = new VisitCountingContext();
859 CreateVisitedLinkFile(context); 860 CreateVisitedLinkFile(context);
860 CreateVisitedLinkMaster(context); 861 CreateVisitedLinkMaster(context);
861 return context; 862 return context;
862 } 863 }
863 864
864 void CreateVisitedLinkFile(content::BrowserContext* browser_context) { 865 void CreateVisitedLinkFile(content::BrowserContext* browser_context) {
865 base::FilePath visited_file = 866 base::FilePath visited_file =
866 browser_context->GetPath().Append(FILE_PATH_LITERAL("Visited Links")); 867 browser_context->GetPath().Append(FILE_PATH_LITERAL("Visited Links"));
867 scoped_ptr<VisitedLinkMaster> master( 868 std::unique_ptr<VisitedLinkMaster> master(
868 new VisitedLinkMaster(new TrackingVisitedLinkEventListener(), 869 new VisitedLinkMaster(new TrackingVisitedLinkEventListener(),
869 &delegate_, true, true, visited_file, 0)); 870 &delegate_, true, true, visited_file, 0));
870 master->Init(); 871 master->Init();
871 // Waiting complete create the table. 872 // Waiting complete create the table.
872 content::RunAllBlockingPoolTasksUntilIdle(); 873 content::RunAllBlockingPoolTasksUntilIdle();
873 874
874 master.reset(); 875 master.reset();
875 // Wait for all pending file I/O to be completed. 876 // Wait for all pending file I/O to be completed.
876 content::RunAllBlockingPoolTasksUntilIdle(); 877 content::RunAllBlockingPoolTasksUntilIdle();
877 } 878 }
878 }; 879 };
879 880
880 TEST_F(VisitedLinkCompletelyResetEventTest, LoadTable) { 881 TEST_F(VisitedLinkCompletelyResetEventTest, LoadTable) {
881 // Waiting complete loading the table. 882 // Waiting complete loading the table.
882 content::RunAllBlockingPoolTasksUntilIdle(); 883 content::RunAllBlockingPoolTasksUntilIdle();
883 884
884 WaitForCoalescence(); 885 WaitForCoalescence();
885 886
886 // After load table expect completely reset event. 887 // After load table expect completely reset event.
887 EXPECT_EQ(1, context()->completely_reset_event_count()); 888 EXPECT_EQ(1, context()->completely_reset_event_count());
888 } 889 }
889 890
890 } // namespace visitedlink 891 } // namespace visitedlink
OLDNEW
« no previous file with comments | « components/visitedlink/browser/visitedlink_master.cc ('k') | components/wallpaper/wallpaper_manager_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698