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

Side by Side Diff: chrome/browser/chromeos/cros/cros_library.h

Issue 1142005: Mocks for all libcros elements (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/browser_main.cc ('k') | chrome/browser/chromeos/cros/cros_library.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_CHROMEOS_CROS_CROS_LIBRARY_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_CROS_CROS_LIBRARY_H_
6 #define CHROME_BROWSER_CHROMEOS_CROS_CROS_LIBRARY_H_ 6 #define CHROME_BROWSER_CHROMEOS_CROS_CROS_LIBRARY_H_
7 7
8 #include <string> 8 #include <string>
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/singleton.h"
10 11
11 namespace chromeos { 12 namespace chromeos {
12 13
13 // This class handles the loading of the ChromeOS shared library. 14 class CryptohomeLibrary;
15 class LanguageLibrary;
16 class LibraryLoader;
17 class LoginLibrary;
18 class MountLibrary;
19 class NetworkLibrary;
20 class PowerLibrary;
21 class SynapticsLibrary;
22
23 // This class handles access to sub-parts of ChromeOS library. it provides
24 // a level of indirection so individual libraries that it exposes can
25 // be mocked for testing.
14 class CrosLibrary { 26 class CrosLibrary {
15 public: 27 public:
28
29 // This class provides access to internal members of CrosLibrary class for
30 // purpose of testing (i.e. replacement of members' implementation with
31 // mock objects).
32 class TestApi {
33 public:
34 // Setter for LibraryLoader.
35 void SetLibraryLoader(LibraryLoader* loader);
36 // Setter for CryptohomeLibrary.
37 void SetCryptohomeLibrary(CryptohomeLibrary* library);
38 // Setter for LanguageLibrary
39 void SetLanguageLibrary(LanguageLibrary* library);
40 // Setter for LoginLibrary.
41 void SetLoginLibrary(LoginLibrary* library);
42 // Setter for MountLibrary.
43 void SetMountLibrary(MountLibrary* library);
44 // Setter for NetworkLibrary.
45 void SetNetworkLibrary(NetworkLibrary* library);
46 // Setter for PowerLibrary.
47 void SetPowerLibrary(PowerLibrary* library);
48 // Setter for SynapticsLibrary.
49 void SetSynapticsLibrary(SynapticsLibrary* library);
50
51 private:
52 friend class CrosLibrary;
53 explicit TestApi(CrosLibrary* library) : library_(library) {}
54 CrosLibrary* library_;
55 };
56
57 // This gets the CrosLibrary.
58 static CrosLibrary* Get();
59
60 // Getter for CryptohomeLibrary.
61 CryptohomeLibrary* GetCryptohomeLibrary();
62
63 // // Getter for LanguageLibrary
64 LanguageLibrary* GetLanguageLibrary();
65
66 // Getter for LoginLibrary.
67 LoginLibrary* GetLoginLibrary();
68
69 // Getter for MountLibrary
70 MountLibrary* GetMountLibrary();
71
72 // Getter for NetworkLibrary
73 NetworkLibrary* GetNetworkLibrary();
74
75 // Getter for PowerLibrary
76 PowerLibrary* GetPowerLibrary();
77
78 // This gets the singleton SynapticsLibrary.
79 SynapticsLibrary* GetSynapticsLibrary();
80
81 // Getter for Test API that gives access to internal members of this class.
82 TestApi* GetTestApi();
83
16 // Ensures that the library is loaded, loading it if needed. If the library 84 // Ensures that the library is loaded, loading it if needed. If the library
17 // could not be loaded, returns false. 85 // could not be loaded, returns false.
18 static bool EnsureLoaded(); 86 bool EnsureLoaded();
19 87
20 // Returns an unlocalized string describing the last load error (if any). 88 // Returns an unlocalized string describing the last load error (if any).
21 static const std::string& load_error_string() { 89 const std::string& load_error_string() {
22 return load_error_string_; 90 return load_error_string_;
23 } 91 }
24 92
25 private: 93 private:
26 CrosLibrary() {} 94 friend struct DefaultSingletonTraits<chromeos::CrosLibrary>;
27 ~CrosLibrary() {} 95 friend class CrosLibrary::TestApi;
28 96
97 CrosLibrary();
98 virtual ~CrosLibrary();
99
100 LibraryLoader* library_loader_;
101 CryptohomeLibrary* crypto_lib_;
102 LanguageLibrary* language_lib_;
103 LoginLibrary* login_lib_;
104 MountLibrary* mount_lib_;
105 NetworkLibrary* network_lib_;
106 PowerLibrary* power_lib_;
107 SynapticsLibrary* synaptics_lib_;
29 // True if libcros was successfully loaded. 108 // True if libcros was successfully loaded.
30 static bool loaded_; 109 bool loaded_;
31 // True if the last load attempt had an error. 110 // True if the last load attempt had an error.
32 static bool load_error_; 111 bool load_error_;
33 // Contains the error string from the last load attempt. 112 // Contains the error string from the last load attempt.
34 static std::string load_error_string_; 113 std::string load_error_string_;
114 TestApi* test_api_;
35 115
36 DISALLOW_COPY_AND_ASSIGN(CrosLibrary); 116 DISALLOW_COPY_AND_ASSIGN(CrosLibrary);
37 }; 117 };
38 118
39 } // namespace chromeos 119 } // namespace chromeos
40 120
41 #endif // CHROME_BROWSER_CHROMEOS_CROS_CROS_LIBRARY_H_ 121 #endif // CHROME_BROWSER_CHROMEOS_CROS_CROS_LIBRARY_H_
OLDNEW
« no previous file with comments | « chrome/browser/browser_main.cc ('k') | chrome/browser/chromeos/cros/cros_library.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698