1 // Copyright 2014 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "base/android/content_uri_utils.h" 6 #include "base/files/file_util.h" 7 #include "base/path_service.h" 8 #include "base/test/test_file_util.h" 9 #include "testing/gtest/include/gtest/gtest.h" 10 11 namespace base { 12 namespace android { 13 14 // Disable test on Android due to flakiness: crbug.com/807080, crbug/1054637. TEST(ContentUriUtilsTest,DISABLED_ContentUriMimeTest)15TEST(ContentUriUtilsTest, DISABLED_ContentUriMimeTest) { 16 // Get the test image path. 17 FilePath data_dir; 18 ASSERT_TRUE(PathService::Get(DIR_TEST_DATA, &data_dir)); 19 data_dir = data_dir.AppendASCII("file_util"); 20 ASSERT_TRUE(PathExists(data_dir)); 21 FilePath image_file = data_dir.Append(FILE_PATH_LITERAL("red.png")); 22 23 // Insert the image into MediaStore. MediaStore will do some conversions, and 24 // return the content URI. 25 FilePath path = base::InsertImageIntoMediaStore(image_file); 26 EXPECT_TRUE(path.IsContentUri()); 27 EXPECT_TRUE(PathExists(path)); 28 29 std::string mime = GetContentUriMimeType(path); 30 EXPECT_EQ(mime, std::string("image/png")); 31 32 FilePath invalid_path("content://foo.bar"); 33 mime = GetContentUriMimeType(invalid_path); 34 EXPECT_TRUE(mime.empty()); 35 } 36 37 } // namespace android 38 } // namespace base 39