| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_MOCK_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_CROS_CROS_MOCK_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_CROS_CROS_MOCK_H_ | 6 #define CHROME_BROWSER_CHROMEOS_CROS_CROS_MOCK_H_ |
| 7 | 7 |
| 8 #include "chrome/browser/chromeos/cros/cros_library.h" | 8 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 9 #include "chrome/browser/chromeos/cros/network_library.h" | 9 #include "chrome/browser/chromeos/cros/network_library.h" |
| 10 #include "chrome/test/base/in_process_browser_test.h" | 10 #include "chrome/test/base/in_process_browser_test.h" |
| 11 | 11 |
| 12 namespace chromeos { | 12 namespace chromeos { |
| 13 | 13 |
| 14 class MockCryptohomeLibrary; | 14 class MockCryptohomeLibrary; |
| 15 class MockKeyboardLibrary; | 15 class MockKeyboardLibrary; |
| 16 class MockLibraryLoader; | 16 class MockLibraryLoader; |
| 17 class MockNetworkLibrary; | 17 class MockNetworkLibrary; |
| 18 class MockPowerLibrary; | 18 class MockPowerLibrary; |
| 19 class MockScreenLockLibrary; | 19 class MockScreenLockLibrary; |
| 20 class MockSpeechSynthesisLibrary; | |
| 21 | 20 |
| 22 // Class for initializing mocks for some parts of CrosLibrary. Once you mock | 21 // Class for initializing mocks for some parts of CrosLibrary. Once you mock |
| 23 // part of CrosLibrary it will be considered as successfully loaded and | 22 // part of CrosLibrary it will be considered as successfully loaded and |
| 24 // libraries that compose CrosLibrary will be created. CrosMock also defines a | 23 // libraries that compose CrosLibrary will be created. CrosMock also defines a |
| 25 // minimum set of mocks that is used by status area elements (network, | 24 // minimum set of mocks that is used by status area elements (network, |
| 26 // input language, power). | 25 // input language, power). |
| 27 class CrosMock { | 26 class CrosMock { |
| 28 public: | 27 public: |
| 29 CrosMock(); | 28 CrosMock(); |
| 30 virtual ~CrosMock(); | 29 virtual ~CrosMock(); |
| 31 | 30 |
| 32 // This method sets up basic mocks that are used by status area items: | 31 // This method sets up basic mocks that are used by status area items: |
| 33 // LibraryLoader, Language, Network, Power, libraries. | 32 // LibraryLoader, Language, Network, Power, libraries. |
| 34 // Add a call to this method at the beginning of your | 33 // Add a call to this method at the beginning of your |
| 35 // SetUpInProcessBrowserTestFixture. | 34 // SetUpInProcessBrowserTestFixture. |
| 36 void InitStatusAreaMocks(); | 35 void InitStatusAreaMocks(); |
| 37 | 36 |
| 38 // Initialization of CrosLibrary mock loader. If you intend calling | 37 // Initialization of CrosLibrary mock loader. If you intend calling |
| 39 // separate init methods for mocks call this one first. | 38 // separate init methods for mocks call this one first. |
| 40 void InitMockLibraryLoader(); | 39 void InitMockLibraryLoader(); |
| 41 | 40 |
| 42 // Initialization of mocks. | 41 // Initialization of mocks. |
| 43 void InitMockCryptohomeLibrary(); | 42 void InitMockCryptohomeLibrary(); |
| 44 void InitMockKeyboardLibrary(); | 43 void InitMockKeyboardLibrary(); |
| 45 void InitMockNetworkLibrary(); | 44 void InitMockNetworkLibrary(); |
| 46 void InitMockPowerLibrary(); | 45 void InitMockPowerLibrary(); |
| 47 void InitMockScreenLockLibrary(); | 46 void InitMockScreenLockLibrary(); |
| 48 void InitMockSpeechSynthesisLibrary(); | |
| 49 | 47 |
| 50 // Get mocks. | 48 // Get mocks. |
| 51 MockCryptohomeLibrary* mock_cryptohome_library(); | 49 MockCryptohomeLibrary* mock_cryptohome_library(); |
| 52 MockKeyboardLibrary* mock_keyboard_library(); | 50 MockKeyboardLibrary* mock_keyboard_library(); |
| 53 MockNetworkLibrary* mock_network_library(); | 51 MockNetworkLibrary* mock_network_library(); |
| 54 MockPowerLibrary* mock_power_library(); | 52 MockPowerLibrary* mock_power_library(); |
| 55 MockScreenLockLibrary* mock_screen_lock_library(); | 53 MockScreenLockLibrary* mock_screen_lock_library(); |
| 56 MockSpeechSynthesisLibrary* mock_speech_synthesis_library(); | |
| 57 | 54 |
| 58 // This method sets up corresponding expectations for basic mocks that | 55 // This method sets up corresponding expectations for basic mocks that |
| 59 // are used by status area items. | 56 // are used by status area items. |
| 60 // Make sure that InitStatusAreaMocks was called before. | 57 // Make sure that InitStatusAreaMocks was called before. |
| 61 // Add a call to this method in your SetUpInProcessBrowserTestFixture. | 58 // Add a call to this method in your SetUpInProcessBrowserTestFixture. |
| 62 // They are all configured with RetiresOnSaturation(). | 59 // They are all configured with RetiresOnSaturation(). |
| 63 // Once such expectation is used it won't block expectations you've defined. | 60 // Once such expectation is used it won't block expectations you've defined. |
| 64 void SetStatusAreaMocksExpectations(); | 61 void SetStatusAreaMocksExpectations(); |
| 65 | 62 |
| 66 // Methods to setup minimal mocks expectations for status area. | 63 // Methods to setup minimal mocks expectations for status area. |
| 67 void SetKeyboardLibraryStatusAreaExpectations(); | 64 void SetKeyboardLibraryStatusAreaExpectations(); |
| 68 void SetNetworkLibraryStatusAreaExpectations(); | 65 void SetNetworkLibraryStatusAreaExpectations(); |
| 69 void SetPowerLibraryStatusAreaExpectations(); | 66 void SetPowerLibraryStatusAreaExpectations(); |
| 70 void SetPowerLibraryExpectations(); | 67 void SetPowerLibraryExpectations(); |
| 71 void SetSpeechSynthesisLibraryExpectations(); | |
| 72 | 68 |
| 73 void TearDownMocks(); | 69 void TearDownMocks(); |
| 74 | 70 |
| 75 // TestApi gives access to CrosLibrary private members. | 71 // TestApi gives access to CrosLibrary private members. |
| 76 chromeos::CrosLibrary::TestApi* test_api(); | 72 chromeos::CrosLibrary::TestApi* test_api(); |
| 77 | 73 |
| 78 private: | 74 private: |
| 79 // Mocks, destroyed by CrosLibrary class. | 75 // Mocks, destroyed by CrosLibrary class. |
| 80 MockLibraryLoader* loader_; | 76 MockLibraryLoader* loader_; |
| 81 MockCryptohomeLibrary* mock_cryptohome_library_; | 77 MockCryptohomeLibrary* mock_cryptohome_library_; |
| 82 MockKeyboardLibrary* mock_keyboard_library_; | 78 MockKeyboardLibrary* mock_keyboard_library_; |
| 83 MockNetworkLibrary* mock_network_library_; | 79 MockNetworkLibrary* mock_network_library_; |
| 84 MockPowerLibrary* mock_power_library_; | 80 MockPowerLibrary* mock_power_library_; |
| 85 MockScreenLockLibrary* mock_screen_lock_library_; | 81 MockScreenLockLibrary* mock_screen_lock_library_; |
| 86 MockSpeechSynthesisLibrary* mock_speech_synthesis_library_; | |
| 87 | 82 |
| 88 WifiNetworkVector wifi_networks_; | 83 WifiNetworkVector wifi_networks_; |
| 89 CellularNetworkVector cellular_networks_; | 84 CellularNetworkVector cellular_networks_; |
| 90 VirtualNetworkVector virtual_networks_; | 85 VirtualNetworkVector virtual_networks_; |
| 91 std::string empty_string_; | 86 std::string empty_string_; |
| 92 | 87 |
| 93 DISALLOW_COPY_AND_ASSIGN(CrosMock); | 88 DISALLOW_COPY_AND_ASSIGN(CrosMock); |
| 94 }; | 89 }; |
| 95 | 90 |
| 96 } // namespace chromeos | 91 } // namespace chromeos |
| 97 | 92 |
| 98 #endif // CHROME_BROWSER_CHROMEOS_CROS_CROS_MOCK_H_ | 93 #endif // CHROME_BROWSER_CHROMEOS_CROS_CROS_MOCK_H_ |
| OLD | NEW |