Flutter Engine
The Flutter Engine
testing
stream_capture.h
Go to the documentation of this file.
1
// Copyright 2013 The Flutter 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
#ifndef FLUTTER_TESTING_STREAM_CAPTURE_H_
6
#define FLUTTER_TESTING_STREAM_CAPTURE_H_
7
8
#include <ostream>
9
#include <sstream>
10
#include <string>
11
12
namespace
flutter
{
13
namespace
testing {
14
15
// Temporarily replaces the specified stream's output buffer to capture output.
16
//
17
// Example:
18
// StreamCapture captured_stdout(&std::cout);
19
// ... code that writest to std::cout ...
20
// std::string output = captured_stdout.GetCapturedOutput();
21
class
StreamCapture
{
22
public
:
23
// Begins capturing output to the specified stream.
24
explicit
StreamCapture
(std::ostream* ostream);
25
26
// Stops capturing output to the specified stream, and restores the original
27
// output buffer, if |Stop| has not already been called.
28
~StreamCapture
();
29
30
// Stops capturing output to the specified stream, and restores the original
31
// output buffer.
32
void
Stop
();
33
34
// Returns any output written to the captured stream between construction and
35
// the first call to |Stop|, if any, or now.
36
std::string
GetOutput
()
const
;
37
38
private
:
39
std::ostream* ostream_;
40
std::stringstream buffer_;
41
std::streambuf* old_buffer_;
42
};
43
44
}
// namespace testing
45
}
// namespace flutter
46
47
#endif
// FLUTTER_TESTING_STREAM_CAPTURE_H_
flutter::testing::StreamCapture
Definition:
stream_capture.h:21
flutter::testing::StreamCapture::~StreamCapture
~StreamCapture()
Definition:
stream_capture.cc:15
flutter::testing::StreamCapture::Stop
void Stop()
Definition:
stream_capture.cc:19
flutter::testing::StreamCapture::StreamCapture
StreamCapture(std::ostream *ostream)
Definition:
stream_capture.cc:10
flutter::testing::StreamCapture::GetOutput
std::string GetOutput() const
Definition:
stream_capture.cc:26
flutter
Definition:
asset_manager.cc:10
Generated on Sun Jun 23 2024 21:55:19 for Flutter Engine by
1.9.4