esim_test_base.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. // Copyright 2020 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. #ifndef ASH_SERVICES_CELLULAR_SETUP_ESIM_TEST_BASE_H_
  5. #define ASH_SERVICES_CELLULAR_SETUP_ESIM_TEST_BASE_H_
  6. #include "ash/services/cellular_setup/public/cpp/esim_manager_test_observer.h"
  7. #include "ash/services/cellular_setup/public/mojom/esim_manager.mojom.h"
  8. #include "base/test/task_environment.h"
  9. #include "mojo/public/cpp/bindings/remote.h"
  10. #include "testing/gtest/include/gtest/gtest.h"
  11. namespace ash {
  12. class CellularInhibitor;
  13. class CellularConnectionHandler;
  14. class CellularESimInstaller;
  15. class CellularESimUninstallHandler;
  16. class NetworkConfigurationHandler;
  17. class NetworkDeviceHandler;
  18. class NetworkProfileHandler;
  19. class NetworkStateHandler;
  20. class FakeNetworkConnectionHandler;
  21. class TestCellularESimProfileHandler;
  22. namespace cellular_setup {
  23. class ESimManager;
  24. // Base class for testing eSIM mojo impl classes.
  25. class ESimTestBase : public testing::Test {
  26. public:
  27. static const char* kTestEuiccPath;
  28. static const char* kTestEid;
  29. // testing::Test:
  30. void SetUp() override;
  31. void TearDown() override;
  32. // Creates a test euicc.
  33. void SetupEuicc();
  34. // Returns list of available euiccs under the test ESimManager.
  35. std::vector<mojo::PendingRemote<mojom::Euicc>> GetAvailableEuiccs();
  36. // Returns euicc with given |eid| under the test ESimManager.
  37. mojo::Remote<mojom::Euicc> GetEuiccForEid(const std::string& eid);
  38. protected:
  39. ESimTestBase();
  40. ~ESimTestBase() override;
  41. void FastForwardProfileRefreshDelay();
  42. ESimManager* esim_manager() { return esim_manager_.get(); }
  43. ESimManagerTestObserver* observer() { return observer_.get(); }
  44. FakeNetworkConnectionHandler* network_connection_handler() {
  45. return network_connection_handler_.get();
  46. }
  47. NetworkStateHandler* network_state_handler() {
  48. return network_state_handler_.get();
  49. }
  50. TestCellularESimProfileHandler* cellular_esim_profile_handler() {
  51. return cellular_esim_profile_handler_.get();
  52. }
  53. base::test::TaskEnvironment* task_environment() { return &task_environment_; }
  54. private:
  55. std::unique_ptr<NetworkStateHandler> network_state_handler_;
  56. std::unique_ptr<NetworkDeviceHandler> network_device_handler_;
  57. std::unique_ptr<CellularInhibitor> cellular_inhibitor_;
  58. std::unique_ptr<CellularESimInstaller> cellular_esim_installer_;
  59. std::unique_ptr<TestCellularESimProfileHandler>
  60. cellular_esim_profile_handler_;
  61. std::unique_ptr<NetworkConfigurationHandler> network_configuration_handler_;
  62. std::unique_ptr<NetworkProfileHandler> network_profile_handler_;
  63. std::unique_ptr<FakeNetworkConnectionHandler> network_connection_handler_;
  64. std::unique_ptr<CellularESimUninstallHandler>
  65. cellular_esim_uninstall_handler_;
  66. std::unique_ptr<CellularConnectionHandler> cellular_connection_handler_;
  67. base::test::TaskEnvironment task_environment_{
  68. base::test::TaskEnvironment::TimeSource::MOCK_TIME};
  69. std::unique_ptr<ESimManager> esim_manager_;
  70. std::unique_ptr<ESimManagerTestObserver> observer_;
  71. };
  72. } // namespace cellular_setup
  73. } // namespace ash
  74. #endif // ASH_SERVICES_CELLULAR_SETUP_ESIM_TEST_BASE_H_