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