Refactor ParcelFileDescriptorIsBuiltinType test

The test was not using TEST_P and iterating each CPP/Java/Rust manually.
Now it's run with TEST_P (exercising NDK as well) and checks output
files.

Bug: n/a
Test: aidl_unittests
Change-Id: Id13ddbabc73e0475af2c734cd850043ef604611b
diff --git a/aidl_unittest.cpp b/aidl_unittest.cpp
index 98dcdb7..2d33bbb 100644
--- a/aidl_unittest.cpp
+++ b/aidl_unittest.cpp
@@ -761,8 +761,7 @@
     for (const auto& [lang, test_case] : expectations) {
       if (lang != GetLanguage()) continue;
       string output;
-      EXPECT_TRUE(io_delegate_.GetWrittenContents(test_case.output_file, &output))
-          << base::Join(io_delegate_.ListOutputFiles(), ",");
+      EXPECT_TRUE(io_delegate_.GetWrittenContents(test_case.output_file, &output));
       EXPECT_THAT(output, HasSubstr(test_case.annotation));
     }
   };
@@ -2739,25 +2738,25 @@
   EXPECT_EQ(expected_stderr, GetCapturedStderr());
 }
 
-TEST_F(AidlTest, ParcelFileDescriptorIsBuiltinType) {
-  Options javaOptions = Options::From("aidl --lang=java -o out p/IFoo.aidl");
-  Options cppOptions = Options::From("aidl --lang=cpp -h out -o out p/IFoo.aidl");
-  Options rustOptions = Options::From("aidl --lang=rust -o out p/IFoo.aidl");
+TEST_P(AidlTest, ParcelFileDescriptorIsBuiltinType) {
+  Options options =
+      Options::From("aidl --lang=" + to_string(GetLanguage()) + " -h out -o out p/IFoo.aidl");
 
   // use without import
   io_delegate_.SetFileContents("p/IFoo.aidl",
                                "package p; interface IFoo{ void foo(in ParcelFileDescriptor fd);}");
-  EXPECT_EQ(0, ::android::aidl::compile_aidl(javaOptions, io_delegate_));
-  EXPECT_EQ(0, ::android::aidl::compile_aidl(cppOptions, io_delegate_));
-  EXPECT_EQ(0, ::android::aidl::compile_aidl(rustOptions, io_delegate_));
+  EXPECT_EQ(0, ::android::aidl::compile_aidl(options, io_delegate_));
+
+  // capture output files
+  map<string, string> outputs = io_delegate_.OutputFiles();
 
   // use without import but with full name
   io_delegate_.SetFileContents(
       "p/IFoo.aidl",
       "package p; interface IFoo{ void foo(in android.os.ParcelFileDescriptor fd);}");
-  EXPECT_EQ(0, ::android::aidl::compile_aidl(javaOptions, io_delegate_));
-  EXPECT_EQ(0, ::android::aidl::compile_aidl(cppOptions, io_delegate_));
-  EXPECT_EQ(0, ::android::aidl::compile_aidl(rustOptions, io_delegate_));
+  EXPECT_EQ(0, ::android::aidl::compile_aidl(options, io_delegate_));
+  // output files should be the same
+  EXPECT_EQ(outputs, io_delegate_.OutputFiles());
 
   // use with import (as before)
   io_delegate_.SetFileContents("p/IFoo.aidl",
@@ -2766,9 +2765,9 @@
                                "interface IFoo{"
                                "  void foo(in ParcelFileDescriptor fd);"
                                "}");
-  EXPECT_EQ(0, ::android::aidl::compile_aidl(javaOptions, io_delegate_));
-  EXPECT_EQ(0, ::android::aidl::compile_aidl(cppOptions, io_delegate_));
-  EXPECT_EQ(0, ::android::aidl::compile_aidl(rustOptions, io_delegate_));
+  EXPECT_EQ(0, ::android::aidl::compile_aidl(options, io_delegate_));
+  // output files should be the same
+  EXPECT_EQ(outputs, io_delegate_.OutputFiles());
 }
 
 TEST_F(AidlTest, ManualIds) {
diff --git a/tests/aidl_parser_fuzzer.cpp b/tests/aidl_parser_fuzzer.cpp
index b4cd485..cbae184 100644
--- a/tests/aidl_parser_fuzzer.cpp
+++ b/tests/aidl_parser_fuzzer.cpp
@@ -37,13 +37,8 @@
     }
     std::cout << std::endl;
 
-    for (const std::string& f : io.ListInputFiles()) {
-      std::unique_ptr<std::string> input = io.GetFileContents(f);
-      if (input == nullptr) {
-        std::cout << "bad io " << f << std::endl;
-        abort();
-      }
-      std::cout << "INPUT " << f << ": " << *input << std::endl;
+    for (const auto& [f, input] : io.InputFiles()) {
+      std::cout << "INPUT " << f << ": " << input << std::endl;
     }
   }
 
@@ -51,12 +46,9 @@
   if (ret != 0) return;
 
   if (kFuzzLog) {
-    for (const std::string& f : io.ListOutputFiles()) {
-      std::string output;
-      if (io.GetWrittenContents(f, &output)) {
-        std::cout << "OUTPUT " << f << ": " << std::endl;
-        std::cout << output << std::endl;
-      }
+    for (const auto& [f, output] : io.OutputFiles()) {
+      std::cout << "OUTPUT " << f << ": " << std::endl;
+      std::cout << output << std::endl;
     }
   }
 }
diff --git a/tests/fake_io_delegate.cpp b/tests/fake_io_delegate.cpp
index 9482e43..a99a20a 100644
--- a/tests/fake_io_delegate.cpp
+++ b/tests/fake_io_delegate.cpp
@@ -152,20 +152,12 @@
   return true;
 }
 
-std::vector<std::string> FakeIoDelegate::ListInputFiles() const {
-  std::vector<std::string> out;
-  for (const auto& [file, contents] : file_contents_) {
-    out.push_back(file);
-  }
-  return out;
+const std::map<std::string, std::string>& FakeIoDelegate::InputFiles() const {
+  return file_contents_;
 }
 
-std::vector<std::string> FakeIoDelegate::ListOutputFiles() const {
-  std::vector<std::string> out;
-  for (const auto& [file, contents] : written_file_contents_) {
-    out.push_back(file);
-  }
-  return out;
+const std::map<std::string, std::string>& FakeIoDelegate::OutputFiles() const {
+  return written_file_contents_;
 }
 
 bool FakeIoDelegate::PathWasRemoved(const std::string& path) {
diff --git a/tests/fake_io_delegate.h b/tests/fake_io_delegate.h
index d687c76..6f24678 100644
--- a/tests/fake_io_delegate.h
+++ b/tests/fake_io_delegate.h
@@ -62,8 +62,8 @@
   // Returns true iff we've previously written to |path|.
   // When we return true, we'll set *contents to the written string.
   bool GetWrittenContents(const std::string& path, std::string* content) const;
-  std::vector<std::string> ListInputFiles() const;
-  std::vector<std::string> ListOutputFiles() const;
+  const std::map<std::string, std::string>& InputFiles() const;
+  const std::map<std::string, std::string>& OutputFiles() const;
 
   bool PathWasRemoved(const std::string& path);