diff options
Diffstat (limited to 'cmds/incidentd/tests/Section_test.cpp')
-rw-r--r-- | cmds/incidentd/tests/Section_test.cpp | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/cmds/incidentd/tests/Section_test.cpp b/cmds/incidentd/tests/Section_test.cpp index 2f6698bc3116..9f92353c2910 100644 --- a/cmds/incidentd/tests/Section_test.cpp +++ b/cmds/incidentd/tests/Section_test.cpp @@ -25,26 +25,27 @@ #include <gtest/gtest.h> #include <string.h> -const int TIMEOUT_PARSER = -1; -const int NOOP_PARSER = 0; -const int REVERSE_PARSER = 1; - -const int QUICK_TIMEOUT_MS = 100; - -const string VARINT_FIELD_1 = "\x08\x96\x01"; // 150 -const string STRING_FIELD_2 = "\x12\vandroidwins"; -const string FIX64_FIELD_3 = "\x19\xff\xff\xff\xff\xff\xff\xff\xff"; // -1 - +using namespace android; using namespace android::base; using namespace android::binder; using namespace android::os; +using namespace android::os::incidentd; using namespace android::util; -using namespace std; using ::testing::StrEq; using ::testing::Test; using ::testing::internal::CaptureStdout; using ::testing::internal::GetCapturedStdout; +const int TIMEOUT_PARSER = -1; +const int NOOP_PARSER = 0; +const int REVERSE_PARSER = 1; + +const int QUICK_TIMEOUT_MS = 100; + +const std::string VARINT_FIELD_1 = "\x08\x96\x01"; // 150 +const std::string STRING_FIELD_2 = "\x12\vandroidwins"; +const std::string FIX64_FIELD_3 = "\x19\xff\xff\xff\xff\xff\xff\xff\xff"; // -1 + // NOTICE: this test requires /system/bin/incident_helper is installed. class SectionTest : public Test { public: @@ -101,7 +102,7 @@ TEST_F(SectionTest, HeaderSection) { requests.add(new ReportRequest(args2, new SimpleListener(), tf.fd)); requests.setMainFd(STDOUT_FILENO); - string content; + std::string content; CaptureStdout(); ASSERT_EQ(NO_ERROR, hs.Execute(&requests)); EXPECT_THAT(GetCapturedStdout(), StrEq("\n\x5" @@ -163,9 +164,9 @@ TEST_F(SectionTest, GZipSection) { size_t fileLen = testFile.size(); size_t totalLen = 1 + get_varint_size(fileLen) + fileLen + 3 + gzFile.size(); uint8_t header[20]; - header[0] = '\x2'; // header 0 << 3 + 2 + header[0] = '\x2'; // header 0 << 3 + 2 uint8_t* ptr = write_raw_varint(header + 1, totalLen); - *ptr = '\n'; // header 1 << 3 + 2 + *ptr = '\n'; // header 1 << 3 + 2 ptr = write_raw_varint(++ptr, fileLen); expected.assign((const char*)header, ptr - header); expected += testFile + "\x12\x9F\x6" + gzFile; @@ -227,7 +228,7 @@ TEST_F(SectionTest, LogSectionBinary) { requests.setMainFd(STDOUT_FILENO); CaptureStdout(); ASSERT_EQ(NO_ERROR, ls.Execute(&requests)); - string results = GetCapturedStdout(); + std::string results = GetCapturedStdout(); EXPECT_FALSE(results.empty()); } @@ -236,7 +237,7 @@ TEST_F(SectionTest, LogSectionSystem) { requests.setMainFd(STDOUT_FILENO); CaptureStdout(); ASSERT_EQ(NO_ERROR, ls.Execute(&requests)); - string results = GetCapturedStdout(); + std::string results = GetCapturedStdout(); EXPECT_FALSE(results.empty()); } @@ -304,7 +305,7 @@ TEST_F(SectionTest, TestMultipleRequests) { ASSERT_EQ(NO_ERROR, fs.Execute(&requests)); EXPECT_THAT(GetCapturedStdout(), StrEq("\x02\r" + STRING_FIELD_2)); - string content, expect; + std::string content, expect; expect = VARINT_FIELD_1 + STRING_FIELD_2 + FIX64_FIELD_3; char c = (char)expect.size(); EXPECT_TRUE(ReadFileToString(output1.path, &content)); @@ -346,7 +347,7 @@ TEST_F(SectionTest, TestMultipleRequestsBySpec) { ASSERT_EQ(NO_ERROR, fs.Execute(&requests)); EXPECT_THAT(GetCapturedStdout(), StrEq("\x02\r" + STRING_FIELD_2)); - string content, expect; + std::string content, expect; expect = STRING_FIELD_2 + FIX64_FIELD_3; char c = (char)expect.size(); |