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

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

Issue 2549103003: tracing: split trace event filter classes out of TraceLog (Closed)
Patch Set: Add BASE_EXPORT Created 4 years 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/event_name_filter.cc ('k') | base/trace_event/heap_profiler_event_filter.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/trace_event/event_name_filter.h"
6
7 #include "base/memory/ptr_util.h"
8 #include "base/trace_event/trace_event_impl.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10
11 namespace base {
12 namespace trace_event {
13
14 const TraceEvent& MakeTraceEvent(const char* name) {
15 static TraceEvent event;
16 event.Reset();
17 event.Initialize(0, TimeTicks(), ThreadTicks(), 'b', nullptr, name, "", 0, 0,
18 0, nullptr, nullptr, nullptr, nullptr, 0);
19 return event;
20 }
21
22 TEST(TraceEventNameFilterTest, Whitelist) {
23 auto empty_whitelist = MakeUnique<EventNameFilter::EventNamesWhitelist>();
24 auto filter = MakeUnique<EventNameFilter>(std::move(empty_whitelist));
25
26 // No events should be filtered if the whitelist is empty.
27 EXPECT_FALSE(filter->FilterTraceEvent(MakeTraceEvent("foo")));
28
29 auto whitelist = MakeUnique<EventNameFilter::EventNamesWhitelist>();
30 whitelist->insert("foo");
31 whitelist->insert("bar");
32 filter = MakeUnique<EventNameFilter>(std::move(whitelist));
33 EXPECT_TRUE(filter->FilterTraceEvent(MakeTraceEvent("foo")));
34 EXPECT_FALSE(filter->FilterTraceEvent(MakeTraceEvent("fooz")));
35 EXPECT_FALSE(filter->FilterTraceEvent(MakeTraceEvent("afoo")));
36 EXPECT_TRUE(filter->FilterTraceEvent(MakeTraceEvent("bar")));
37 EXPECT_FALSE(filter->FilterTraceEvent(MakeTraceEvent("foobar")));
38 }
39
40 } // namespace trace_event
41 } // namespace base
OLDNEW
« no previous file with comments | « base/trace_event/event_name_filter.cc ('k') | base/trace_event/heap_profiler_event_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698