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

Side by Side Diff: tools/cygprofile/cygprofile_unittest.cc

Issue 1869503004: Convert //tools to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase, change iwyu fixes for converted directories to include <memory> Created 4 years, 8 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
« no previous file with comments | « tools/cygprofile/cygprofile.cc ('k') | tools/gn/build_settings.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "tools/cygprofile/cygprofile.h" 5 #include "tools/cygprofile/cygprofile.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <sys/time.h> 8 #include <sys/time.h>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 TEST(CygprofileTest, ManagerBasic) { 63 TEST(CygprofileTest, ManagerBasic) {
64 base::WaitableEvent wait_event(true, false); 64 base::WaitableEvent wait_event(true, false);
65 base::WaitableEvent notify_event(true, false); 65 base::WaitableEvent notify_event(true, false);
66 66
67 ThreadLogsManager manager( 67 ThreadLogsManager manager(
68 base::Bind(&base::WaitableEvent::Wait, base::Unretained(&wait_event)), 68 base::Bind(&base::WaitableEvent::Wait, base::Unretained(&wait_event)),
69 base::Bind(&base::WaitableEvent::Signal, 69 base::Bind(&base::WaitableEvent::Signal,
70 base::Unretained(&notify_event))); 70 base::Unretained(&notify_event)));
71 71
72 std::vector<LogEntry> entries; 72 std::vector<LogEntry> entries;
73 scoped_ptr<ThreadLog> thread_log( 73 std::unique_ptr<ThreadLog> thread_log(
74 new ThreadLog(base::Bind(&FlushEntries, base::Unretained(&entries)))); 74 new ThreadLog(base::Bind(&FlushEntries, base::Unretained(&entries))));
75 75
76 thread_log->AddEntry(reinterpret_cast<void*>(0x2)); 76 thread_log->AddEntry(reinterpret_cast<void*>(0x2));
77 thread_log->AddEntry(reinterpret_cast<void*>(0x3)); 77 thread_log->AddEntry(reinterpret_cast<void*>(0x3));
78 78
79 // This should make the manager spawn its internal flush thread which will 79 // This should make the manager spawn its internal flush thread which will
80 // wait for a notification before it starts doing some work. 80 // wait for a notification before it starts doing some work.
81 manager.AddLog(std::move(thread_log)); 81 manager.AddLog(std::move(thread_log));
82 82
83 EXPECT_EQ(0U, entries.size()); 83 EXPECT_EQ(0U, entries.size());
84 // This will wake up the internal thread. 84 // This will wake up the internal thread.
85 wait_event.Signal(); 85 wait_event.Signal();
86 // Now it's our turn to wait until it performed the flush. 86 // Now it's our turn to wait until it performed the flush.
87 notify_event.Wait(); 87 notify_event.Wait();
88 88
89 // The flush should have moved the data to the local vector of entries. 89 // The flush should have moved the data to the local vector of entries.
90 EXPECT_EQ(2U, entries.size()); 90 EXPECT_EQ(2U, entries.size());
91 ASSERT_EQ(2U, reinterpret_cast<uintptr_t>(entries[0].address)); 91 ASSERT_EQ(2U, reinterpret_cast<uintptr_t>(entries[0].address));
92 ASSERT_EQ(3U, reinterpret_cast<uintptr_t>(entries[1].address)); 92 ASSERT_EQ(3U, reinterpret_cast<uintptr_t>(entries[1].address));
93 } 93 }
94 94
95 } // namespace 95 } // namespace
96 } // namespace cygprofile 96 } // namespace cygprofile
97 97
98 // Custom runner implementation since base's one requires JNI on Android. 98 // Custom runner implementation since base's one requires JNI on Android.
99 int main(int argc, char** argv) { 99 int main(int argc, char** argv) {
100 testing::InitGoogleTest(&argc, argv); 100 testing::InitGoogleTest(&argc, argv);
101 return RUN_ALL_TESTS(); 101 return RUN_ALL_TESTS();
102 } 102 }
OLDNEW
« no previous file with comments | « tools/cygprofile/cygprofile.cc ('k') | tools/gn/build_settings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698