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

Side by Side Diff: base/trace_event/trace_event_unittest.cc

Issue 1141793003: Update from https://crrev.com/329939 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 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
« no previous file with comments | « base/trace_event/trace_event_memory.cc ('k') | base/tracked_objects.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 (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 <math.h> 5 #include <math.h>
6 #include <cstdlib> 6 #include <cstdlib>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 1509 matching lines...) Expand 10 before | Expand all | Expand 10 after
1520 // So, we'll have thread names for threads we didn't create. 1520 // So, we'll have thread names for threads we didn't create.
1521 std::vector<const DictionaryValue*> items = 1521 std::vector<const DictionaryValue*> items =
1522 FindTraceEntries(trace_parsed_, "thread_name"); 1522 FindTraceEntries(trace_parsed_, "thread_name");
1523 for (int i = 0; i < static_cast<int>(items.size()); i++) { 1523 for (int i = 0; i < static_cast<int>(items.size()); i++) {
1524 item = items[i]; 1524 item = items[i];
1525 ASSERT_TRUE(item); 1525 ASSERT_TRUE(item);
1526 EXPECT_TRUE(item->GetInteger("tid", &tmp_int)); 1526 EXPECT_TRUE(item->GetInteger("tid", &tmp_int));
1527 1527
1528 // See if this thread name is one of the threads we just created 1528 // See if this thread name is one of the threads we just created
1529 for (int j = 0; j < kNumThreads; j++) { 1529 for (int j = 0; j < kNumThreads; j++) {
1530 if(static_cast<int>(thread_ids[j]) != tmp_int) 1530 if (static_cast<int>(thread_ids[j]) != tmp_int)
1531 continue; 1531 continue;
1532 1532
1533 std::string expected_name = StringPrintf("Thread %d", j); 1533 std::string expected_name = StringPrintf("Thread %d", j);
1534 EXPECT_TRUE(item->GetString("ph", &tmp) && tmp == "M"); 1534 EXPECT_TRUE(item->GetString("ph", &tmp) && tmp == "M");
1535 EXPECT_TRUE(item->GetInteger("pid", &tmp_int) && 1535 EXPECT_TRUE(item->GetInteger("pid", &tmp_int) &&
1536 tmp_int == static_cast<int>(base::GetCurrentProcId())); 1536 tmp_int == static_cast<int>(base::GetCurrentProcId()));
1537 // If the thread name changes or the tid gets reused, the name will be 1537 // If the thread name changes or the tid gets reused, the name will be
1538 // a comma-separated list of thread names, so look for a substring. 1538 // a comma-separated list of thread names, so look for a substring.
1539 EXPECT_TRUE(item->GetString("args.name", &tmp) && 1539 EXPECT_TRUE(item->GetString("args.name", &tmp) &&
1540 tmp.find(expected_name) != std::string::npos); 1540 tmp.find(expected_name) != std::string::npos);
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after
2207 2207
2208 class TraceEventCallbackTest : public TraceEventTestFixture { 2208 class TraceEventCallbackTest : public TraceEventTestFixture {
2209 public: 2209 public:
2210 void SetUp() override { 2210 void SetUp() override {
2211 TraceEventTestFixture::SetUp(); 2211 TraceEventTestFixture::SetUp();
2212 ASSERT_EQ(NULL, s_instance); 2212 ASSERT_EQ(NULL, s_instance);
2213 s_instance = this; 2213 s_instance = this;
2214 } 2214 }
2215 void TearDown() override { 2215 void TearDown() override {
2216 TraceLog::GetInstance()->SetDisabled(); 2216 TraceLog::GetInstance()->SetDisabled();
2217 ASSERT_TRUE(!!s_instance); 2217 ASSERT_TRUE(s_instance);
2218 s_instance = NULL; 2218 s_instance = NULL;
2219 TraceEventTestFixture::TearDown(); 2219 TraceEventTestFixture::TearDown();
2220 } 2220 }
2221 2221
2222 protected: 2222 protected:
2223 // For TraceEventCallbackAndRecordingX tests. 2223 // For TraceEventCallbackAndRecordingX tests.
2224 void VerifyCallbackAndRecordedEvents(size_t expected_callback_count, 2224 void VerifyCallbackAndRecordedEvents(size_t expected_callback_count,
2225 size_t expected_recorded_count) { 2225 size_t expected_recorded_count) {
2226 // Callback events. 2226 // Callback events.
2227 EXPECT_EQ(expected_callback_count, collected_events_names_.size()); 2227 EXPECT_EQ(expected_callback_count, collected_events_names_.size());
(...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after
3075 EXPECT_EQ(original_option.record_mode, new_options.record_mode); 3075 EXPECT_EQ(original_option.record_mode, new_options.record_mode);
3076 EXPECT_EQ(original_option.enable_sampling, new_options.enable_sampling); 3076 EXPECT_EQ(original_option.enable_sampling, new_options.enable_sampling);
3077 EXPECT_EQ(original_option.enable_systrace, new_options.enable_systrace); 3077 EXPECT_EQ(original_option.enable_systrace, new_options.enable_systrace);
3078 } 3078 }
3079 } 3079 }
3080 } 3080 }
3081 } 3081 }
3082 3082
3083 } // namespace trace_event 3083 } // namespace trace_event
3084 } // namespace base 3084 } // namespace base
OLDNEW
« no previous file with comments | « base/trace_event/trace_event_memory.cc ('k') | base/tracked_objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698