Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1831)

Unified Diff: chrome/browser/extensions/api/media_galleries/media_galleries_apitest.cc

Issue 86743002: [MediaGalleries] Enable iPhoto gallery (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Take out logging -- found race Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/media_galleries/media_galleries_apitest.cc
diff --git a/chrome/browser/extensions/api/media_galleries/media_galleries_apitest.cc b/chrome/browser/extensions/api/media_galleries/media_galleries_apitest.cc
index 477ebb1925231fbc10de57a1e964b776c7710429..978eb5421b1a2a53d40c06b2db726bb6cd80d8ea 100644
--- a/chrome/browser/extensions/api/media_galleries/media_galleries_apitest.cc
+++ b/chrome/browser/extensions/api/media_galleries/media_galleries_apitest.cc
@@ -6,19 +6,24 @@
#include "base/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/json/json_writer.h"
+#include "base/mac/scoped_cftyperef.h"
vandebo (ex-Chrome) 2014/01/06 18:45:03 Should all/most of the new includes be in a MAC_OS
Greg Billock 2014/01/07 16:50:55 Yeah, the trybots squealed about this.
#include "base/path_service.h"
#include "base/safe_numerics.h"
+#include "base/strings/string_util.h"
+#include "base/strings/sys_string_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "chrome/browser/apps/app_browsertest_util.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/extension_system.h"
+#include "chrome/browser/media_galleries/fileapi/iapps_finder_impl.h"
#include "chrome/browser/media_galleries/media_file_system_registry.h"
#include "chrome/browser/media_galleries/media_galleries_preferences.h"
#include "chrome/browser/media_galleries/media_galleries_test_util.h"
#include "chrome/browser/storage_monitor/storage_info.h"
#include "chrome/browser/storage_monitor/storage_monitor.h"
#include "chrome/common/chrome_paths.h"
+#include "components/policy/core/common/preferences_mock_mac.h"
#include "content/public/test/test_utils.h"
#if defined(OS_WIN) || defined(OS_MACOSX)
@@ -28,6 +33,11 @@
#include "chrome/common/media_galleries/pmp_test_util.h"
#endif
+#if defined(OS_MACOSX)
+#include "base/mac/foundation_util.h"
+#include "base/strings/sys_string_conversions.h"
+#endif // OS_MACOSX
+
using extensions::PlatformAppBrowserTest;
namespace {
@@ -100,7 +110,9 @@ class MediaGalleriesPlatformAppBrowserTest : public PlatformAppBrowserTest {
}
base::AutoReset<base::FilePath> reset(&test_data_dir_, temp_dir.path());
- return RunPlatformAppTestWithArg(extension_name, custom_arg);
+ bool result = RunPlatformAppTestWithArg(extension_name, custom_arg);
+ content::RunAllPendingInMessageLoop(); // avoid race on exit in registry.
+ return result;
}
void AttachFakeDevice() {
@@ -196,7 +208,108 @@ class MediaGalleriesPlatformAppBrowserTest : public PlatformAppBrowserTest {
ASSERT_TRUE(base::CopyFile(
test_jpg_path, fake_folder_2.AppendASCII("InFirstAlbumOnly.jpg")));
}
-#endif
+#endif // defined(OS_WIN) || defined(OS_MACOSX)
+
+#if defined(OS_MACOSX)
+ void PopulateIPhotoTestData(const base::FilePath& iphoto_data_root) {
+ std::string xml_contents = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<plist version=\"1.0\">"
+ "<dict>\n"
+
+ " <key>List of Albums</key>"
+ " <array>\n"
+
+ " <dict>\n"
+ " <key>AlbumId</key>"
+ " <integer>1</integer>"
+ " <key>AlbumName</key>"
+ " <string>Album1</string>"
+ " <key>KeyList</key>\n"
+ " <array>"
+ " <string>1</string>"
+ " <string>2</string>"
+ " </array>\n"
+ " </dict>\n"
+
+ " <dict>\n"
+ " <key>AlbumId</key>"
+ " <integer>2</integer>"
+ " <key>AlbumName</key>"
+ " <string>Album2</string>"
+ " <key>KeyList</key>\n"
+ " <array>"
+ " <string>2</string>"
+ " </array>\n"
+ " </dict>\n"
+
+ " </array>\n"
+
+ " <key>Master Image List</key>\n"
+ " <dict>\n"
+
+ " <key>1</key>"
+ " <dict>\n"
+ " <key>MediaType</key>"
+ " <string>Image</string>"
+ " <key>Caption</key>"
+ " <string>caption 1</string>"
+ " <key>GUID</key>"
+ " <string>1</string>"
+ " <key>ModDateAsTimerInterval</key>"
+ " <string>386221543.0000</string>"
+ " <key>DateAsTimerInterval</key>"
+ " <string>386221543.0000</string>"
+ " <key>DateAsTimerIntervalGMT</key>"
+ " <string>385123456.00</string>"
+ " <key>ImagePath</key>"
+ " <string>$path1</string>"
+ " <key>ThumbPath</key>"
+ " <string>/thumb/path</string>\n"
+ " </dict>\n"
+
+ " <key>2</key>\n"
+ " <dict>\n"
+ " <key>MediaType</key>"
+ " <string>Image</string>"
+ " <key>Caption</key>"
+ " <string>caption 2</string>"
+ " <key>GUID</key>"
+ " <string>2</string>"
+ " <key>ModDateAsTimerInterval</key>"
+ " <string>386221543.0000</string>"
+ " <key>DateAsTimerInterval</key>"
+ " <string>386221543.0000</string>"
+ " <key>DateAsTimerIntervalGMT</key>"
+ " <string>385123456.00</string>"
+ " <key>ImagePath</key>"
+ " <string>$path2</string>"
+ " <key>ThumbPath</key>"
+ " <string>/thumb/path2</string>\n"
+ " </dict>\n"
+
+ " </dict>\n" // Master Image List
+
+ "</dict>\n"
+ "</plist>";
+
+ base::FilePath test_jpg_path = GetCommonDataDir().AppendASCII("test.jpg");
+ ASSERT_TRUE(base::CreateDirectory(iphoto_data_root));
+ base::FilePath first_only_jpg =
+ iphoto_data_root.AppendASCII("InFirstAlbumOnly.jpg");
+ base::FilePath in_both_jpg = iphoto_data_root.AppendASCII("InBoth.jpg");
+ ASSERT_TRUE(base::CopyFile(test_jpg_path, first_only_jpg));
+ ASSERT_TRUE(base::CopyFile(test_jpg_path, in_both_jpg));
+ ReplaceFirstSubstringAfterOffset(
+ &xml_contents, 0, std::string("$path1"), first_only_jpg.value());
+ ReplaceFirstSubstringAfterOffset(
+ &xml_contents, 0, std::string("$path2"), in_both_jpg.value());
+
+ base::FilePath album_xml = iphoto_data_root.AppendASCII("AlbumData.xml");
+ ASSERT_NE(-1, file_util::WriteFile(album_xml,
+ xml_contents.c_str(),
+ xml_contents.size()));
+ }
+#endif // defined(OS_MACOSX)
base::FilePath GetCommonDataDir() const {
return test_data_dir_.AppendASCII("api_test")
@@ -321,3 +434,27 @@ IN_PROC_BROWSER_TEST_F(MediaGalleriesPlatformAppBrowserTest,
ASSERT_TRUE(RunMediaGalleriesTestWithArg("picasa", custom_args)) << message_;
}
#endif // defined(OS_WIN) || defined(OS_MACOSX)
+
+#if defined(OS_MACOSX)
+IN_PROC_BROWSER_TEST_F(MediaGalleriesPlatformAppBrowserTest,
+ IPhotoTest) {
+ MockPreferences prefs;
+ base::FilePath iphoto_xml =
+ ensure_media_directories_exists()->GetFakeIPhotoRootPath().
+ AppendASCII("AlbumData.xml");
+ prefs.AddTestItem(
+ base::mac::NSToCFCast(iapps::kIPhotoRecentDatabasesKey),
+ base::mac::NSToCFCast(iapps::NSArrayFromFilePath(iphoto_xml)),
+ false);
+ iapps::SetMacPreferencesForTesting(&prefs);
+
+ PopulateIPhotoTestData(
+ ensure_media_directories_exists()->GetFakeIPhotoRootPath());
+
+ base::ListValue custom_args;
+ custom_args.AppendInteger(test_jpg_size());
+ ASSERT_TRUE(RunMediaGalleriesTestWithArg("iphoto", custom_args)) << message_;
+
+ iapps::SetMacPreferencesForTesting(NULL);
+}
+#endif // defined(OS_MACOSX)

Powered by Google App Engine
This is Rietveld 408576698