Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(120)

Unified Diff: components/arc/kiosk/arc_kiosk_bridge_unittest.cc

Issue 2811303003: arc: Add unit tests for ArcKioskBridge (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/arc/BUILD.gn ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « components/arc/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698