Home | History | Annotate | Download | only in media_galleries
      1 // Copyright (c) 2012 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 
      5 #ifndef CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_GALLERIES_TEST_UTIL_H_
      6 #define CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_GALLERIES_TEST_UTIL_H_
      7 
      8 #include <string>
      9 #include <vector>
     10 
     11 #include "base/basictypes.h"
     12 #include "base/files/scoped_temp_dir.h"
     13 #include "base/memory/ref_counted.h"
     14 #include "base/memory/scoped_ptr.h"
     15 #include "base/test/scoped_path_override.h"
     16 
     17 #if defined(OS_WIN)
     18 #include "base/test/test_reg_util_win.h"
     19 #endif
     20 
     21 namespace extensions {
     22 class Extension;
     23 }
     24 
     25 namespace registry_util {
     26 class RegistryOverrideManager;
     27 }
     28 
     29 class Profile;
     30 
     31 #if defined(OS_MACOSX)
     32 class MockPreferences;
     33 #endif
     34 
     35 scoped_refptr<extensions::Extension> AddMediaGalleriesApp(
     36     const std::string& name,
     37     const std::vector<std::string>& media_galleries_permissions,
     38     Profile* profile);
     39 
     40 class EnsureMediaDirectoriesExists {
     41  public:
     42   EnsureMediaDirectoriesExists();
     43   ~EnsureMediaDirectoriesExists();
     44 
     45   int num_galleries() const { return num_galleries_; }
     46 
     47   base::FilePath GetFakeAppDataPath() const;
     48 
     49   // Changes the directories for the media paths (music, pictures, videos)
     50   // overrides to new, different directories that are generated.
     51   void ChangeMediaPathOverrides();
     52 #if defined(OS_WIN)
     53   base::FilePath GetFakeLocalAppDataPath() const;
     54 #endif
     55 #if defined(OS_WIN) || defined(OS_MACOSX)
     56   void SetCustomPicasaAppDataPath(const base::FilePath& path);
     57   base::FilePath GetFakePicasaFoldersRootPath() const;
     58 #endif
     59 
     60 #if defined(OS_MACOSX)
     61   base::FilePath GetFakeITunesRootPath() const;
     62   base::FilePath GetFakeIPhotoRootPath() const;
     63 #endif
     64 
     65  private:
     66   void Init();
     67 
     68   base::ScopedTempDir fake_dir_;
     69 
     70   int num_galleries_;
     71 
     72   int times_overrides_changed_;
     73 
     74   scoped_ptr<base::ScopedPathOverride> app_data_override_;
     75   scoped_ptr<base::ScopedPathOverride> music_override_;
     76   scoped_ptr<base::ScopedPathOverride> pictures_override_;
     77   scoped_ptr<base::ScopedPathOverride> video_override_;
     78 #if defined(OS_WIN)
     79   scoped_ptr<base::ScopedPathOverride> local_app_data_override_;
     80 
     81   registry_util::RegistryOverrideManager registry_override_;
     82 #endif
     83 #if defined(OS_MACOSX)
     84   scoped_ptr<MockPreferences> mac_preferences_;
     85 #endif
     86 
     87   DISALLOW_COPY_AND_ASSIGN(EnsureMediaDirectoriesExists);
     88 };
     89 
     90 extern base::FilePath MakeMediaGalleriesTestingPath(const std::string& dir);
     91 
     92 #endif  // CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_GALLERIES_TEST_UTIL_H_
     93