Fix metrics_unittests on Android.

The metrics_unittests tried to write an empty file to the
current working directory, which caused a crash on Android. By
using the output folder instead, this is avoided.
This makes it possible to re-enable the tests disabled in r4474
and also remove the empty dummy test added in r4627.

BUG=1882,
TEST=Setup a Chromium+WebRTC checkout as described in issue 1882
. build/android/envsetup.sh
export GYP_DEFINES="$GYP_DEFINES include_tests=1 enable_tracing=1"
gclient runhooks
ninja -C out/Release metrics_unittests_apk
build/android/test_runner.py gtest -s metrics_unittests --verbose --release

R=henrike@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/2127006

git-svn-id: http://webrtc.googlecode.com/svn/trunk/webrtc@4634 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/test/testsupport/metrics/video_metrics_unittest.cc b/test/testsupport/metrics/video_metrics_unittest.cc
index 21f86aa..ba59b2f 100644
--- a/test/testsupport/metrics/video_metrics_unittest.cc
+++ b/test/testsupport/metrics/video_metrics_unittest.cc
@@ -12,11 +12,9 @@
 
 #include "testing/gtest/include/gtest/gtest.h"
 #include "webrtc/test/testsupport/fileutils.h"
-#include "webrtc/test/testsupport/gtest_disable.h"
 
 namespace webrtc {
 
-static const char* kEmptyFileName = "video_metrics_unittest_empty_file.tmp";
 static const char* kNonExistingFileName = "video_metrics_unittest_non_existing";
 static const int kWidth = 352;
 static const int kHeight = 288;
@@ -30,39 +28,39 @@
 class VideoMetricsTest: public testing::Test {
  protected:
   VideoMetricsTest() {
+    empty_file_ = webrtc::test::OutputPath() +
+        "video_metrics_unittest_empty_file.tmp";
     video_file_ = webrtc::test::ResourcePath("foreman_cif_short", "yuv");
   }
   virtual ~VideoMetricsTest() {}
   void SetUp() {
     // Create an empty file:
-    FILE* dummy = fopen(kEmptyFileName, "wb");
+    FILE* dummy = fopen(empty_file_.c_str(), "wb");
     fclose(dummy);
   }
   void TearDown() {
-    remove(kEmptyFileName);
+    remove(empty_file_.c_str());
   }
   webrtc::test::QualityMetricsResult psnr_result_;
   webrtc::test::QualityMetricsResult ssim_result_;
+  std::string empty_file_;
   std::string video_file_;
 };
 
 // Tests that it is possible to run with the same reference as test file
-TEST_F(VideoMetricsTest,
-       DISABLED_ON_ANDROID(ReturnsPerfectResultForIdenticalFilesPSNR)) {
+TEST_F(VideoMetricsTest, ReturnsPerfectResultForIdenticalFilesPSNR) {
   EXPECT_EQ(0, I420PSNRFromFiles(video_file_.c_str(), video_file_.c_str(),
                                  kWidth, kHeight, &psnr_result_));
   EXPECT_EQ(kPsnrPerfectResult, psnr_result_.average);
 }
 
-TEST_F(VideoMetricsTest,
-       DISABLED_ON_ANDROID(ReturnsPerfectResultForIdenticalFilesSSIM)) {
+TEST_F(VideoMetricsTest, ReturnsPerfectResultForIdenticalFilesSSIM) {
   EXPECT_EQ(0, I420SSIMFromFiles(video_file_.c_str(), video_file_.c_str(),
                                  kWidth, kHeight, &ssim_result_));
   EXPECT_EQ(kSsimPerfectResult, ssim_result_.average);
 }
 
-TEST_F(VideoMetricsTest,
-       DISABLED_ON_ANDROID(ReturnsPerfectResultForIdenticalFilesBothMetrics)) {
+TEST_F(VideoMetricsTest, ReturnsPerfectResultForIdenticalFilesBothMetrics) {
   EXPECT_EQ(0, I420MetricsFromFiles(video_file_.c_str(), video_file_.c_str(),
                                     kWidth, kHeight, &psnr_result_,
                                     &ssim_result_));
@@ -71,19 +69,19 @@
 }
 
 // Tests that the right return code is given when the reference file is missing.
-TEST_F(VideoMetricsTest, DISABLED_ON_ANDROID(MissingReferenceFilePSNR)) {
+TEST_F(VideoMetricsTest, MissingReferenceFilePSNR) {
   EXPECT_EQ(kMissingReferenceFileReturnCode,
             I420PSNRFromFiles(kNonExistingFileName, video_file_.c_str(),
                               kWidth, kHeight, &ssim_result_));
 }
 
-TEST_F(VideoMetricsTest, DISABLED_ON_ANDROID(MissingReferenceFileSSIM)) {
+TEST_F(VideoMetricsTest, MissingReferenceFileSSIM) {
   EXPECT_EQ(kMissingReferenceFileReturnCode,
             I420SSIMFromFiles(kNonExistingFileName, video_file_.c_str(),
                               kWidth, kHeight, &ssim_result_));
 }
 
-TEST_F(VideoMetricsTest, DISABLED_ON_ANDROID(MissingReferenceFileBothMetrics)) {
+TEST_F(VideoMetricsTest, MissingReferenceFileBothMetrics) {
   EXPECT_EQ(kMissingReferenceFileReturnCode,
             I420MetricsFromFiles(kNonExistingFileName, video_file_.c_str(),
                                  kWidth, kHeight,
@@ -91,19 +89,19 @@
 }
 
 // Tests that the right return code is given when the test file is missing.
-TEST_F(VideoMetricsTest, DISABLED_ON_ANDROID(MissingTestFilePSNR)) {
+TEST_F(VideoMetricsTest, MissingTestFilePSNR) {
   EXPECT_EQ(kMissingTestFileReturnCode,
             I420PSNRFromFiles(video_file_.c_str(), kNonExistingFileName,
                               kWidth, kHeight, &ssim_result_));
 }
 
-TEST_F(VideoMetricsTest, DISABLED_ON_ANDROID(MissingTestFileSSIM)) {
+TEST_F(VideoMetricsTest, MissingTestFileSSIM) {
   EXPECT_EQ(kMissingTestFileReturnCode,
             I420SSIMFromFiles(video_file_.c_str(), kNonExistingFileName,
                               kWidth, kHeight, &ssim_result_));
 }
 
-TEST_F(VideoMetricsTest, DISABLED_ON_ANDROID(MissingTestFileBothMetrics)) {
+TEST_F(VideoMetricsTest, MissingTestFileBothMetrics) {
   EXPECT_EQ(kMissingTestFileReturnCode,
             I420MetricsFromFiles(video_file_.c_str(), kNonExistingFileName,
                                  kWidth, kHeight,
@@ -111,40 +109,33 @@
 }
 
 // Tests that the method can be executed with empty files.
-TEST_F(VideoMetricsTest, DISABLED_ON_ANDROID(EmptyFilesPSNR)) {
+TEST_F(VideoMetricsTest, EmptyFilesPSNR) {
   EXPECT_EQ(kEmptyFileReturnCode,
-            I420PSNRFromFiles(kEmptyFileName, video_file_.c_str(),
+            I420PSNRFromFiles(empty_file_.c_str(), video_file_.c_str(),
                               kWidth, kHeight, &ssim_result_));
   EXPECT_EQ(kEmptyFileReturnCode,
-            I420PSNRFromFiles(video_file_.c_str(), kEmptyFileName,
+            I420PSNRFromFiles(video_file_.c_str(), empty_file_.c_str(),
                               kWidth, kHeight, &ssim_result_));
 }
 
-TEST_F(VideoMetricsTest, DISABLED_ON_ANDROID(EmptyFilesSSIM)) {
+TEST_F(VideoMetricsTest, EmptyFilesSSIM) {
   EXPECT_EQ(kEmptyFileReturnCode,
-            I420SSIMFromFiles(kEmptyFileName, video_file_.c_str(),
+            I420SSIMFromFiles(empty_file_.c_str(), video_file_.c_str(),
                               kWidth, kHeight, &ssim_result_));
   EXPECT_EQ(kEmptyFileReturnCode,
-            I420SSIMFromFiles(video_file_.c_str(), kEmptyFileName,
+            I420SSIMFromFiles(video_file_.c_str(), empty_file_.c_str(),
                               kWidth, kHeight, &ssim_result_));
 }
 
-TEST_F(VideoMetricsTest, DISABLED_ON_ANDROID(EmptyFilesBothMetrics)) {
+TEST_F(VideoMetricsTest, EmptyFilesBothMetrics) {
   EXPECT_EQ(kEmptyFileReturnCode,
-            I420MetricsFromFiles(kEmptyFileName, video_file_.c_str(),
+            I420MetricsFromFiles(empty_file_.c_str(), video_file_.c_str(),
                                  kWidth, kHeight,
                                  &psnr_result_, &ssim_result_));
   EXPECT_EQ(kEmptyFileReturnCode,
-              I420MetricsFromFiles(video_file_.c_str(), kEmptyFileName,
+              I420MetricsFromFiles(video_file_.c_str(), empty_file_.c_str(),
                                    kWidth, kHeight,
                                    &psnr_result_, &ssim_result_));
 }
 
-// Dummy test to get at least one test in this executable for Android
-// (otherwise gtest will fail execution on Android).
-// TODO(kjellander): Remove when the other tests have been fixed for
-// Android.
-TEST_F(VideoMetricsTest, DummyTest) {
-}
-
 }  // namespace webrtc