AAPT2: Move all file output to FileOutputStream
FileOutputStream is safe to use on Windows, as it opens files using our compatibility API. Bug: 68262818 Test: make aapt2_tests Change-Id: Ib0b27e93edd609b49b1327db7d9867a002198ebb
This commit is contained in:
@@ -16,8 +16,12 @@
|
||||
|
||||
#include "java/AnnotationProcessor.h"
|
||||
|
||||
#include "io/StringStream.h"
|
||||
#include "test/Test.h"
|
||||
#include "text/Printer.h"
|
||||
|
||||
using ::aapt::io::StringOutputStream;
|
||||
using ::aapt::text::Printer;
|
||||
using ::testing::Eq;
|
||||
using ::testing::HasSubstr;
|
||||
using ::testing::Not;
|
||||
@@ -33,9 +37,11 @@ TEST(AnnotationProcessorTest, EmitsDeprecated) {
|
||||
AnnotationProcessor processor;
|
||||
processor.AppendComment(comment);
|
||||
|
||||
std::stringstream result;
|
||||
processor.WriteToStream("", &result);
|
||||
std::string annotations = result.str();
|
||||
std::string annotations;
|
||||
StringOutputStream out(&annotations);
|
||||
Printer printer(&out);
|
||||
processor.Print(&printer);
|
||||
out.Flush();
|
||||
|
||||
EXPECT_THAT(annotations, HasSubstr("@Deprecated"));
|
||||
}
|
||||
@@ -44,9 +50,11 @@ TEST(AnnotationProcessorTest, EmitsSystemApiAnnotationAndRemovesFromComment) {
|
||||
AnnotationProcessor processor;
|
||||
processor.AppendComment("@SystemApi This is a system API");
|
||||
|
||||
std::stringstream result;
|
||||
processor.WriteToStream("", &result);
|
||||
std::string annotations = result.str();
|
||||
std::string annotations;
|
||||
StringOutputStream out(&annotations);
|
||||
Printer printer(&out);
|
||||
processor.Print(&printer);
|
||||
out.Flush();
|
||||
|
||||
EXPECT_THAT(annotations, HasSubstr("@android.annotation.SystemApi"));
|
||||
EXPECT_THAT(annotations, Not(HasSubstr("@SystemApi")));
|
||||
@@ -57,9 +65,11 @@ TEST(AnnotationProcessorTest, EmitsTestApiAnnotationAndRemovesFromComment) {
|
||||
AnnotationProcessor processor;
|
||||
processor.AppendComment("@TestApi This is a test API");
|
||||
|
||||
std::stringstream result;
|
||||
processor.WriteToStream("", &result);
|
||||
std::string annotations = result.str();
|
||||
std::string annotations;
|
||||
StringOutputStream out(&annotations);
|
||||
Printer printer(&out);
|
||||
processor.Print(&printer);
|
||||
out.Flush();
|
||||
|
||||
EXPECT_THAT(annotations, HasSubstr("@android.annotation.TestApi"));
|
||||
EXPECT_THAT(annotations, Not(HasSubstr("@TestApi")));
|
||||
|
||||
Reference in New Issue
Block a user