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

Unified Diff: components/arc/arc_bridge_service_unittest.cc

Issue 2031143002: Add unit tests for ArcBridgeService::RemoveObserver() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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/arc_bridge_service.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/arc/arc_bridge_service_unittest.cc
diff --git a/components/arc/arc_bridge_service_unittest.cc b/components/arc/arc_bridge_service_unittest.cc
index eaafa7958cffde00fe6f0a5b2b07d9ad6694b0bc..0027542a40d526154306070c0a5d83aea7fca579 100644
--- a/components/arc/arc_bridge_service_unittest.cc
+++ b/components/arc/arc_bridge_service_unittest.cc
@@ -19,6 +19,8 @@
namespace arc {
+namespace {
+
class ArcBridgeTest : public testing::Test, public ArcBridgeService::Observer {
public:
ArcBridgeTest() : ready_(false) {}
@@ -56,7 +58,7 @@ class ArcBridgeTest : public testing::Test, public ArcBridgeService::Observer {
instance_.reset(new FakeArcBridgeInstance());
service_.reset(new ArcBridgeServiceImpl(
- base::WrapUnique(new FakeArcBridgeBootstrap(instance_.get()))));
+ base::MakeUnique<FakeArcBridgeBootstrap>(instance_.get())));
service_->AddObserver(this);
}
@@ -76,6 +78,10 @@ class ArcBridgeTest : public testing::Test, public ArcBridgeService::Observer {
DISALLOW_COPY_AND_ASSIGN(ArcBridgeTest);
};
+class DummyObserver : public ArcBridgeService::Observer {};
+
+} // namespace
+
// Exercises the basic functionality of the ARC Bridge Service. A message from
// within the instance should cause the observer to be notified.
TEST_F(ArcBridgeTest, Basic) {
@@ -138,4 +144,18 @@ TEST_F(ArcBridgeTest, Restart) {
ASSERT_EQ(ArcBridgeService::State::STOPPED, state());
}
+// Removing the same observer more than once should be okay.
+TEST_F(ArcBridgeTest, RemoveObserverTwice) {
+ ASSERT_FALSE(ready());
+ service_->RemoveObserver(this);
+ // The teardown method will also remove |this|.
+}
+
+// Removing an unknown observer should be allowed.
+TEST_F(ArcBridgeTest, RemoveUnknownObserver) {
+ ASSERT_FALSE(ready());
+ auto dummy_observer = base::MakeUnique<DummyObserver>();
+ service_->RemoveObserver(dummy_observer.get());
+}
+
} // namespace arc
« no previous file with comments | « components/arc/arc_bridge_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698