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