content_uri_utils_unittest.cc 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright 2014 The Chromium 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. #include "base/android/content_uri_utils.h"
  5. #include "base/files/file_util.h"
  6. #include "base/path_service.h"
  7. #include "base/test/test_file_util.h"
  8. #include "testing/gtest/include/gtest/gtest.h"
  9. namespace base {
  10. namespace android {
  11. // Disable test on Android due to flakiness: crbug.com/807080, crbug/1054637.
  12. TEST(ContentUriUtilsTest, DISABLED_ContentUriMimeTest) {
  13. // Get the test image path.
  14. FilePath data_dir;
  15. ASSERT_TRUE(PathService::Get(DIR_TEST_DATA, &data_dir));
  16. data_dir = data_dir.AppendASCII("file_util");
  17. ASSERT_TRUE(PathExists(data_dir));
  18. FilePath image_file = data_dir.Append(FILE_PATH_LITERAL("red.png"));
  19. // Insert the image into MediaStore. MediaStore will do some conversions, and
  20. // return the content URI.
  21. FilePath path = base::InsertImageIntoMediaStore(image_file);
  22. EXPECT_TRUE(path.IsContentUri());
  23. EXPECT_TRUE(PathExists(path));
  24. std::string mime = GetContentUriMimeType(path);
  25. EXPECT_EQ(mime, std::string("image/png"));
  26. FilePath invalid_path("content://foo.bar");
  27. mime = GetContentUriMimeType(invalid_path);
  28. EXPECT_TRUE(mime.empty());
  29. }
  30. } // namespace android
  31. } // namespace base