Index: components/arc/kiosk/arc_kiosk_bridge_unittest.cc |
diff --git a/components/arc/kiosk/arc_kiosk_bridge_unittest.cc b/components/arc/kiosk/arc_kiosk_bridge_unittest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..4136c7358359f89d0e27e7d6887b54e237cccb02 |
--- /dev/null |
+++ b/components/arc/kiosk/arc_kiosk_bridge_unittest.cc |
@@ -0,0 +1,65 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include <memory> |
+ |
+#include "base/macros.h" |
+#include "base/memory/ptr_util.h" |
+#include "components/arc/arc_bridge_service.h" |
+#include "components/arc/kiosk/arc_kiosk_bridge.h" |
+#include "testing/gmock/include/gmock/gmock.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+ |
+namespace { |
+ |
+class MockArcKioskBridgeDelegate : public arc::ArcKioskBridge::Delegate { |
+ public: |
+ MockArcKioskBridgeDelegate() {} |
Luis Héctor Chávez
2017/04/12 18:24:41
nit: = default
Sergey Poromov
2017/04/13 11:08:31
Done.
|
+ |
+ MOCK_METHOD0(OnMaintenanceSessionCreated, void()); |
+ MOCK_METHOD0(OnMaintenanceSessionFinished, void()); |
+}; |
+ |
+} // namespace |
+ |
+namespace arc { |
+ |
+class ArcKioskBridgeTest : public testing::Test { |
+ public: |
+ ArcKioskBridgeTest() {} |
Luis Héctor Chávez
2017/04/12 18:24:41
nit: = default
Sergey Poromov
2017/04/13 11:08:32
Done.
|
+ |
+ void SetUp() override { |
+ 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.
|
+ delegate_ = base::MakeUnique<MockArcKioskBridgeDelegate>(); |
+ kiosk_bridge_ = base::MakeUnique<ArcKioskBridge>(bridge_service_.get(), |
+ delegate_.get()); |
+ } |
+ |
+ protected: |
+ ArcKioskBridge* kiosk_bridge() { return kiosk_bridge_.get(); } |
+ MockArcKioskBridgeDelegate* delegate() { return delegate_.get(); } |
+ |
+ private: |
+ 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.
|
+ std::unique_ptr<MockArcKioskBridgeDelegate> delegate_; |
+ std::unique_ptr<ArcKioskBridge> kiosk_bridge_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(ArcKioskBridgeTest); |
+}; |
+ |
+TEST_F(ArcKioskBridgeTest, MaintenanceSessionFinished) { |
+ EXPECT_CALL(*delegate(), OnMaintenanceSessionCreated()).Times(1); |
+ kiosk_bridge()->OnMaintenanceSessionCreated(1); |
+ EXPECT_CALL(*delegate(), OnMaintenanceSessionFinished()).Times(1); |
+ kiosk_bridge()->OnMaintenanceSessionFinished(1, true); |
+} |
+ |
+TEST_F(ArcKioskBridgeTest, MaintenanceSessionNotFinished) { |
+ EXPECT_CALL(*delegate(), OnMaintenanceSessionCreated()).Times(1); |
+ kiosk_bridge()->OnMaintenanceSessionCreated(1); |
+ EXPECT_CALL(*delegate(), OnMaintenanceSessionFinished()).Times(0); |
+ kiosk_bridge()->OnMaintenanceSessionFinished(2, true); |
+} |
+ |
+} // namespace arc |