Use using ::testing::* declarations in tracing_service_impl_unittest
Change-Id: Ic6312302bec2afdd90416a0ebb51c46d954ddc97
diff --git a/src/tracing/core/tracing_service_impl_unittest.cc b/src/tracing/core/tracing_service_impl_unittest.cc
index c1ad5cd..4648d25 100644
--- a/src/tracing/core/tracing_service_impl_unittest.cc
+++ b/src/tracing/core/tracing_service_impl_unittest.cc
@@ -43,16 +43,22 @@
#include "perfetto/trace/trace_packet.pbzero.h"
using ::testing::_;
+using ::testing::AssertionFailure;
+using ::testing::AssertionResult;
+using ::testing::AssertionSuccess;
using ::testing::Contains;
using ::testing::ElementsAreArray;
using ::testing::Eq;
+using ::testing::ExplainMatchResult;
using ::testing::InSequence;
using ::testing::Invoke;
using ::testing::InvokeWithoutArgs;
+using ::testing::IsEmpty;
using ::testing::Mock;
using ::testing::Not;
using ::testing::Property;
using ::testing::StrictMock;
+using ::testing::StringMatchResultListener;
namespace perfetto {
@@ -62,11 +68,11 @@
TracingServiceImpl::kDefaultShmPageSize / 1024;
constexpr size_t kMaxShmSizeKb = TracingServiceImpl::kMaxShmSize / 1024;
-::testing::AssertionResult HasTriggerModeInternal(
+AssertionResult HasTriggerModeInternal(
const std::vector<protos::TracePacket>& packets,
protos::TraceConfig::TriggerConfig::TriggerMode mode) {
- ::testing::StringMatchResultListener matcher_result_string;
- bool contains = ::testing::ExplainMatchResult(
+ StringMatchResultListener matcher_result_string;
+ bool contains = ExplainMatchResult(
Contains(Property(
&protos::TracePacket::trace_config,
Property(&protos::TraceConfig::trigger_config,
@@ -74,9 +80,9 @@
Eq(mode))))),
packets, &matcher_result_string);
if (contains) {
- return ::testing::AssertionSuccess();
+ return AssertionSuccess();
}
- return ::testing::AssertionFailure() << matcher_result_string.str();
+ return AssertionFailure() << matcher_result_string.str();
}
MATCHER_P(HasTriggerMode, mode, "") {
@@ -214,7 +220,7 @@
consumer_a->DisableTracing();
consumer_a->WaitForTracingDisabled();
- EXPECT_THAT(consumer_b->ReadBuffers(), ::testing::IsEmpty());
+ EXPECT_THAT(consumer_b->ReadBuffers(), IsEmpty());
}
TEST_F(TracingServiceImplTest, RegisterAndUnregister) {
@@ -366,7 +372,7 @@
producer->WaitForDataSourceStop("ds_1");
consumer->WaitForTracingDisabled();
- EXPECT_THAT(consumer->ReadBuffers(), ::testing::IsEmpty());
+ EXPECT_THAT(consumer->ReadBuffers(), IsEmpty());
}
// Creates a tracing session with a START_TRACING trigger and checks that
@@ -414,7 +420,7 @@
producer->WaitForDataSourceStop("ds_1");
consumer->WaitForTracingDisabled();
- EXPECT_THAT(consumer->ReadBuffers(), ::testing::IsEmpty());
+ EXPECT_THAT(consumer->ReadBuffers(), IsEmpty());
}
// Creates a tracing session with a START_TRACING trigger and checks that the
@@ -506,7 +512,7 @@
producer->WaitForDataSourceStop("ds_1");
consumer->WaitForTracingDisabled();
- EXPECT_THAT(consumer->ReadBuffers(), ::testing::IsEmpty());
+ EXPECT_THAT(consumer->ReadBuffers(), IsEmpty());
}
// Creates a tracing session with a START_TRACING trigger and checks that any
@@ -754,10 +760,8 @@
Eq(kServicePacketSequenceID))));
};
EXPECT_THAT(packets, expect_received_trigger("trigger_name"));
- EXPECT_THAT(packets,
- ::testing::Not(expect_received_trigger("trigger_name_2")));
- EXPECT_THAT(packets,
- ::testing::Not(expect_received_trigger("trigger_name_3")));
+ EXPECT_THAT(packets, Not(expect_received_trigger("trigger_name_2")));
+ EXPECT_THAT(packets, Not(expect_received_trigger("trigger_name_3")));
}
// Creates a tracing session with a START_TRACING trigger and checks that the
@@ -832,8 +836,7 @@
Eq(kServicePacketSequenceID))));
};
EXPECT_THAT(packets, expect_received_trigger("trigger_name"));
- EXPECT_THAT(packets,
- ::testing::Not(expect_received_trigger("trigger_name_2")));
+ EXPECT_THAT(packets, Not(expect_received_trigger("trigger_name_2")));
EXPECT_THAT(packets, expect_received_trigger("trigger_name_3"));
}
@@ -895,8 +898,7 @@
&protos::TraceConfig::TriggerConfig::trigger_mode,
Eq(protos::TraceConfig::TriggerConfig::STOP_TRACING))))));
EXPECT_THAT(packets, expect_received_trigger("trigger_name"));
- EXPECT_THAT(packets,
- ::testing::Not(expect_received_trigger("trigger_name_2")));
+ EXPECT_THAT(packets, Not(expect_received_trigger("trigger_name_2")));
// Send a new trigger.
producer->endpoint()->ActivateTriggers({"trigger_name_2"});
@@ -914,7 +916,7 @@
packets = consumer->ReadBuffers();
// We don't rewrite the old trigger.
- EXPECT_THAT(packets, ::testing::Not(expect_received_trigger("trigger_name")));
+ EXPECT_THAT(packets, Not(expect_received_trigger("trigger_name")));
EXPECT_THAT(packets, expect_received_trigger("trigger_name_2"));
}
@@ -952,7 +954,7 @@
producer->WaitForDataSourceStart("ds_1");
// The trace won't return data until unless we send a trigger at this point.
- EXPECT_THAT(consumer->ReadBuffers(), ::testing::IsEmpty());
+ EXPECT_THAT(consumer->ReadBuffers(), IsEmpty());
auto writer = producer->CreateTraceWriter("ds_1");
producer->WaitForFlush(writer.get());
@@ -961,7 +963,7 @@
producer->WaitForDataSourceStop("ds_1");
consumer->WaitForTracingDisabled();
- EXPECT_THAT(consumer->ReadBuffers(), ::testing::IsEmpty());
+ EXPECT_THAT(consumer->ReadBuffers(), IsEmpty());
}
// Creates a tracing session with a STOP_TRACING trigger and checks that the
@@ -996,7 +998,7 @@
producer->WaitForDataSourceStart("ds_1");
// The trace won't return data until unless we send a trigger at this point.
- EXPECT_THAT(consumer->ReadBuffers(), ::testing::IsEmpty());
+ EXPECT_THAT(consumer->ReadBuffers(), IsEmpty());
// We write into the buffer a large packet which takes up the whole buffer. We
// then add a bunch of smaller ones which causes the larger packet to be
@@ -1052,10 +1054,9 @@
// The large payload was overwritten before we trigger and ReadBuffers so it
// should not be in the returned data.
- EXPECT_THAT(packets,
- ::testing::Not(Contains(Property(
- &protos::TracePacket::for_testing,
- Property(&protos::TestEvent::str, Eq(large_payload))))));
+ EXPECT_THAT(packets, Not(Contains(Property(&protos::TracePacket::for_testing,
+ Property(&protos::TestEvent::str,
+ Eq(large_payload))))));
}
// Creates a tracing session with a STOP_TRACING trigger and checks that the
@@ -1092,7 +1093,7 @@
producer->WaitForDataSourceStart("ds_1");
// The trace won't return data until unless we send a trigger at this point.
- EXPECT_THAT(consumer->ReadBuffers(), ::testing::IsEmpty());
+ EXPECT_THAT(consumer->ReadBuffers(), IsEmpty());
std::vector<std::string> req;
req.push_back("trigger_name");
@@ -1582,7 +1583,7 @@
ASSERT_EQ(4u, GetNumPendingFlushes());
// Make the producer reply only to the 3rd flush request.
- testing::InSequence seq;
+ InSequence seq;
producer->WaitForFlush(nullptr, /*reply=*/false); // Do NOT reply to flush 1.
producer->WaitForFlush(nullptr, /*reply=*/false); // Do NOT reply to flush 2.
producer->WaitForFlush(writer.get()); // Reply only to flush 3.
@@ -1900,7 +1901,7 @@
producer2->Connect(svc.get(), "mock_producer2");
producer2->RegisterDataSource("ds_2A");
- testing::InSequence seq;
+ InSequence seq;
TracingSessionID last_session_id = 0;
for (int i = 0; i < 3; i++) {
TraceConfig trace_config;