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

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

Issue 23513059: Media Galleries API Picasa: End-to-end browsertest. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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
« no previous file with comments | « no previous file | chrome/browser/media_galleries/fileapi/picasa_file_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 8d8b3413fba9a265e8a31279b0a0d74c2a48a640..29f1bc834c0a97a50fe565bb9b4364a3c3bdf69a 100644
--- a/chrome/browser/extensions/api/media_galleries/media_galleries_apitest.cc
+++ b/chrome/browser/extensions/api/media_galleries/media_galleries_apitest.cc
@@ -23,6 +23,13 @@
#include "content/public/test/test_utils.h"
#include "extensions/common/switches.h"
+#if defined(OS_WIN) || defined(OS_MACOSX)
+#include "chrome/browser/media_galleries/fileapi/picasa_finder.h"
+#include "chrome/common/media_galleries/picasa_test_util.h"
+#include "chrome/common/media_galleries/picasa_types.h"
+#include "chrome/common/media_galleries/pmp_test_util.h"
+#endif
+
using extensions::PlatformAppBrowserTest;
namespace {
@@ -38,8 +45,6 @@ base::FilePath::CharType kDevicePath[] = FILE_PATH_LITERAL("/qux");
const char kTestGalleries[] = "testGalleries(%d)";
-} // namespace
-
// This function is to ensure at least one (fake) media gallery exists for
// testing platforms with no default media galleries, such as CHROMEOS.
void MakeFakeMediaGalleryForTest(Profile* profile, const base::FilePath& path) {
@@ -64,6 +69,8 @@ void MakeFakeMediaGalleryForTest(Profile* profile, const base::FilePath& path) {
content::RunAllPendingInMessageLoop();
}
+} // namespace
+
class MediaGalleriesPlatformAppBrowserTest : public PlatformAppBrowserTest {
protected:
// Since ExtensionTestMessageListener does not work with RunPlatformAppTest(),
@@ -95,6 +102,27 @@ class MediaGalleriesPlatformAppBrowserTest : public PlatformAppBrowserTest {
content::RunAllPendingInMessageLoop();
}
+#if defined(OS_WIN) || defined(OS_MACOSX)
+ // This initializes the storage monitor, MediaGalleriesPreferences, and
+ // injects a custom Picasa database location.
+ void SetMediaGalleriesPreferencesForPicasaTest(
+ Profile* profile,
+ const base::FilePath& database_path) {
+ base::RunLoop runloop;
+ StorageMonitor::GetInstance()->EnsureInitialized(runloop.QuitClosure());
+ runloop.Run();
+
+ MediaGalleriesPreferences* preferences =
+ g_browser_process->media_file_system_registry()->GetPreferences(
+ profile);
+
+ content::RunAllPendingInMessageLoop();
tommycli 2013/09/18 15:25:37 The Picasa gallery is not found unless I have this
vandebo (ex-Chrome) 2013/09/18 15:49:34 Probably because the picasa finder runs async from
+
+ preferences->OnPicasaDeviceID(StorageInfo::MakeDeviceId(
+ StorageInfo::PICASA, database_path.AsUTF8Unsafe()));
+ }
+#endif
+
private:
std::string device_id_;
};
@@ -173,3 +201,41 @@ IN_PROC_BROWSER_TEST_F(MediaGalleriesPlatformAppBrowserTest,
ASSERT_TRUE(RunPlatformAppTest("api_test/media_galleries/metadata"))
<< message_;
}
+
+#if defined(OS_WIN) || defined(OS_MACOSX)
+IN_PROC_BROWSER_TEST_F(MediaGalleriesPlatformAppBrowserTest, Picasa) {
+ EnsureMediaDirectoriesExists media_directories;
+
+ // Create Picasa metadata database directories.
+ base::ScopedTempDir metadata_root;
+ ASSERT_TRUE(metadata_root.CreateUniqueTempDir());
+ base::FilePath picasa_database_path =
+ metadata_root.path().AppendASCII(picasa::kPicasaDatabaseDirName);
+ base::FilePath picasa_temp_dir_path =
+ metadata_root.path().AppendASCII(picasa::kPicasaTempDirName);
+ ASSERT_TRUE(file_util::CreateDirectory(picasa_database_path));
+ ASSERT_TRUE(file_util::CreateDirectory(picasa_temp_dir_path));
+
+ // Create fake folder directories.
+ base::ScopedTempDir folders_root;
+ ASSERT_TRUE(folders_root.CreateUniqueTempDir());
+ base::FilePath fake_folder_1 = folders_root.path().AppendASCII("folder1");
+ base::FilePath fake_folder_2 = folders_root.path().AppendASCII("folder2");
+ ASSERT_TRUE(file_util::CreateDirectory(fake_folder_1));
+ ASSERT_TRUE(file_util::CreateDirectory(fake_folder_2));
+
+ // Write folder and album contents.
+ picasa::WriteTestAlbumTable(
+ picasa_database_path, fake_folder_1, fake_folder_2);
+ picasa::WriteTestAlbumsImagesIndex(fake_folder_1, fake_folder_2);
+ picasa::WriteJPEGHeader(fake_folder_1.AppendASCII("InBoth.jpg"));
+ picasa::WriteJPEGHeader(fake_folder_1.AppendASCII("InSecondAlbumOnly.jpg"));
+ picasa::WriteJPEGHeader(fake_folder_2.AppendASCII("InFirstAlbumOnly.jpg"));
+
+ SetMediaGalleriesPreferencesForPicasaTest(browser()->profile(),
+ picasa_database_path);
+
+ ASSERT_TRUE(RunPlatformAppTest("api_test/media_galleries/picasa"))
+ << message_;
+}
+#endif // defined(OS_WIN) || defined(OS_MACOSX)
« no previous file with comments | « no previous file | chrome/browser/media_galleries/fileapi/picasa_file_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698