summaryrefslogtreecommitdiffstats
path: root/chrome/browser/media_galleries/media_galleries_test_util.h
blob: 599aa24cad19331ae5c78bba2bef0783d0f47ea7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_GALLERIES_TEST_UTIL_H_
#define CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_GALLERIES_TEST_UTIL_H_

#include <string>
#include <vector>

#include "base/basictypes.h"
#include "base/files/scoped_temp_dir.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/test/scoped_path_override.h"

#if defined(OS_WIN)
#include "base/test/test_reg_util_win.h"
#endif

namespace extensions {
class Extension;
}

namespace registry_util {
class RegistryOverrideManager;
}

class Profile;

#if defined(OS_MACOSX)
class MockPreferences;
#endif

scoped_refptr<extensions::Extension> AddMediaGalleriesApp(
    const std::string& name,
    const std::vector<std::string>& media_galleries_permissions,
    Profile* profile);

class EnsureMediaDirectoriesExists {
 public:
  EnsureMediaDirectoriesExists();
  ~EnsureMediaDirectoriesExists();

  int num_galleries() const { return num_galleries_; }

  base::FilePath GetFakeAppDataPath() const;

  // Changes the directories for the media paths (music, pictures, videos)
  // overrides to new, different directories that are generated.
  void ChangeMediaPathOverrides();
#if defined(OS_WIN)
  base::FilePath GetFakeLocalAppDataPath() const;
#endif
#if defined(OS_WIN) || defined(OS_MACOSX)
  void SetCustomPicasaAppDataPath(const base::FilePath& path);
  base::FilePath GetFakePicasaFoldersRootPath() const;
#endif

#if defined(OS_MACOSX)
  base::FilePath GetFakeITunesRootPath() const;
  base::FilePath GetFakeIPhotoRootPath() const;
#endif

 private:
  void Init();

  base::ScopedTempDir fake_dir_;

  int num_galleries_;

  int times_overrides_changed_;

  scoped_ptr<base::ScopedPathOverride> app_data_override_;
  scoped_ptr<base::ScopedPathOverride> music_override_;
  scoped_ptr<base::ScopedPathOverride> pictures_override_;
  scoped_ptr<base::ScopedPathOverride> video_override_;
#if defined(OS_WIN)
  scoped_ptr<base::ScopedPathOverride> local_app_data_override_;

  registry_util::RegistryOverrideManager registry_override_;
#endif
#if defined(OS_MACOSX)
  scoped_ptr<MockPreferences> mac_preferences_;
#endif

  DISALLOW_COPY_AND_ASSIGN(EnsureMediaDirectoriesExists);
};

extern base::FilePath MakeMediaGalleriesTestingPath(const std::string& dir);

#endif  // CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_GALLERIES_TEST_UTIL_H_