Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 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 #include <memory> | |
| 6 | |
| 7 #include "base/macros.h" | |
| 8 #include "base/memory/ptr_util.h" | |
| 9 #include "components/arc/arc_bridge_service.h" | |
| 10 #include "components/arc/kiosk/arc_kiosk_bridge.h" | |
| 11 #include "testing/gmock/include/gmock/gmock.h" | |
| 12 #include "testing/gtest/include/gtest/gtest.h" | |
| 13 | |
| 14 namespace { | |
| 15 | |
| 16 class MockArcKioskBridgeDelegate : public arc::ArcKioskBridge::Delegate { | |
| 17 public: | |
| 18 MockArcKioskBridgeDelegate() {} | |
|
Luis Héctor Chávez
2017/04/12 18:24:41
nit: = default
Sergey Poromov
2017/04/13 11:08:31
Done.
| |
| 19 | |
| 20 MOCK_METHOD0(OnMaintenanceSessionCreated, void()); | |
| 21 MOCK_METHOD0(OnMaintenanceSessionFinished, void()); | |
| 22 }; | |
| 23 | |
| 24 } // namespace | |
| 25 | |
| 26 namespace arc { | |
| 27 | |
| 28 class ArcKioskBridgeTest : public testing::Test { | |
| 29 public: | |
| 30 ArcKioskBridgeTest() {} | |
|
Luis Héctor Chávez
2017/04/12 18:24:41
nit: = default
Sergey Poromov
2017/04/13 11:08:32
Done.
| |
| 31 | |
| 32 void SetUp() override { | |
| 33 bridge_service_ = base::MakeUnique<ArcBridgeService>(); | |
|
Daniel Erat
2017/04/12 18:29:31
consider putting initialization in the c'tor inste
Sergey Poromov
2017/04/13 11:08:31
Done.
| |
| 34 delegate_ = base::MakeUnique<MockArcKioskBridgeDelegate>(); | |
| 35 kiosk_bridge_ = base::MakeUnique<ArcKioskBridge>(bridge_service_.get(), | |
| 36 delegate_.get()); | |
| 37 } | |
| 38 | |
| 39 protected: | |
| 40 ArcKioskBridge* kiosk_bridge() { return kiosk_bridge_.get(); } | |
| 41 MockArcKioskBridgeDelegate* delegate() { return delegate_.get(); } | |
| 42 | |
| 43 private: | |
| 44 std::unique_ptr<ArcBridgeService> bridge_service_; | |
|
Daniel Erat
2017/04/12 18:29:31
consider moving these members into the 'protected'
Sergey Poromov
2017/04/13 11:08:31
Done.
| |
| 45 std::unique_ptr<MockArcKioskBridgeDelegate> delegate_; | |
| 46 std::unique_ptr<ArcKioskBridge> kiosk_bridge_; | |
| 47 | |
| 48 DISALLOW_COPY_AND_ASSIGN(ArcKioskBridgeTest); | |
| 49 }; | |
| 50 | |
| 51 TEST_F(ArcKioskBridgeTest, MaintenanceSessionFinished) { | |
| 52 EXPECT_CALL(*delegate(), OnMaintenanceSessionCreated()).Times(1); | |
| 53 kiosk_bridge()->OnMaintenanceSessionCreated(1); | |
| 54 EXPECT_CALL(*delegate(), OnMaintenanceSessionFinished()).Times(1); | |
| 55 kiosk_bridge()->OnMaintenanceSessionFinished(1, true); | |
| 56 } | |
| 57 | |
| 58 TEST_F(ArcKioskBridgeTest, MaintenanceSessionNotFinished) { | |
| 59 EXPECT_CALL(*delegate(), OnMaintenanceSessionCreated()).Times(1); | |
| 60 kiosk_bridge()->OnMaintenanceSessionCreated(1); | |
| 61 EXPECT_CALL(*delegate(), OnMaintenanceSessionFinished()).Times(0); | |
| 62 kiosk_bridge()->OnMaintenanceSessionFinished(2, true); | |
| 63 } | |
| 64 | |
| 65 } // namespace arc | |
| OLD | NEW |