summaryrefslogtreecommitdiff
path: root/base/include/android-base/test_utils.h
diff options
context:
space:
mode:
authorChristopher Ferris <cferris@google.com>2018-08-30 13:31:45 -0700
committerChristopher Ferris <cferris@google.com>2018-09-04 14:29:23 -0700
commiteea85c9aabf38d39e0474716df3b10502ced9586 (patch)
treef8982eaa50950ff776df46f8b6cce211cdaf02bd /base/include/android-base/test_utils.h
parent640ceee567c7f7e3832f9de189580fd3e138e951 (diff)
Add Start/Stop/Reset to CapturedStdFd.
Move the fd() function to be private since it should not have been exposed in the first place. Fix the way logging_test uses CapturedXXX. Adding this because the new isolated testing doesn't print errors to stderr so the ASSERT_ EXPECT_ messages can get swallowed. Also, it's easier to reuse a CapturedXXX object in a test with these functions. Test: New unit tests pass. Change-Id: I38b113fc184146ce434802f80a9b7997fa83e78a
Diffstat (limited to 'base/include/android-base/test_utils.h')
-rw-r--r--base/include/android-base/test_utils.h10
1 files changed, 6 insertions, 4 deletions
diff --git a/base/include/android-base/test_utils.h b/base/include/android-base/test_utils.h
index 9e2ea97f23..2abe68e026 100644
--- a/base/include/android-base/test_utils.h
+++ b/base/include/android-base/test_utils.h
@@ -62,16 +62,18 @@ class CapturedStdFd {
CapturedStdFd(int std_fd);
~CapturedStdFd();
- int fd() const;
std::string str();
- private:
- void Init();
+ void Start();
+ void Stop();
void Reset();
+ private:
+ int fd() const;
+
TemporaryFile temp_file_;
int std_fd_;
- int old_fd_;
+ int old_fd_ = -1;
DISALLOW_COPY_AND_ASSIGN(CapturedStdFd);
};