Use custom mkstemp() to fix Win issue in y4m_test

Uses mkstmp() with directory being the same as the test data
directory to create temporary output file. For Windows
GetTempFileNameA() function is used.

Change-Id: Ie4681b2b4f44f8c22d3b3faf134c44087b484f94
diff --git a/test/y4m_test.cc b/test/y4m_test.cc
index 73ff683..3927b7d 100644
--- a/test/y4m_test.cc
+++ b/test/y4m_test.cc
@@ -138,14 +138,11 @@
 class Y4mVideoWriteTest
     : public Y4mVideoSourceTest {
  protected:
-  Y4mVideoWriteTest() : Y4mVideoSourceTest() {}
+  Y4mVideoWriteTest() {}
 
-  virtual void ReplaceInputFp(FILE *input_file) {
+  virtual ~Y4mVideoWriteTest() {
     CloseSource();
-    frame_ = 0;
-    input_file_ = input_file;
-    rewind(input_file_);
-    ReadSourceToStart();
+    delete tmpfile_;
   }
 
   // Writes out a y4m file and then reads it back
@@ -153,26 +150,28 @@
     ASSERT_TRUE(input_file_ != NULL);
     char buf[Y4M_BUFFER_SIZE] = {0};
     const struct VpxRational framerate = {y4m_.fps_n, y4m_.fps_d};
-    FILE *out_file = libvpx_test::OpenTempOutFile();
-    ASSERT_TRUE(out_file != NULL);
+    tmpfile_ = new libvpx_test::TempOutFile;
+    ASSERT_TRUE(tmpfile_->file() != NULL);
     y4m_write_file_header(buf, sizeof(buf),
                           kWidth, kHeight,
                           &framerate, y4m_.vpx_fmt,
                           y4m_.bit_depth);
-    fputs(buf, out_file);
+    fputs(buf, tmpfile_->file());
     for (unsigned int i = start_; i < limit_; i++) {
       y4m_write_frame_header(buf, sizeof(buf));
-      fputs(buf, out_file);
-      write_image_file(img(), out_file);
+      fputs(buf, tmpfile_->file());
+      write_image_file(img(), tmpfile_->file());
       Next();
     }
-    ReplaceInputFp(out_file);
+    tmpfile_->CloseFile();
+    Y4mVideoSourceTest::Init(tmpfile_->file_name(), limit_);
   }
 
   virtual void Init(const std::string &file_name, int limit) {
     Y4mVideoSourceTest::Init(file_name, limit);
     WriteY4mAndReadBack();
   }
+  libvpx_test::TempOutFile *tmpfile_;
 };
 
 TEST_P(Y4mVideoWriteTest, WriteTest) {