| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/bubble/bubble_manager.h" | 5 #include "components/bubble/bubble_manager.h" |
| 6 | 6 |
| 7 #include <memory> |
| 7 #include <utility> | 8 #include <utility> |
| 8 | 9 |
| 9 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/ptr_util.h" |
| 10 #include "components/bubble/bubble_controller.h" | 12 #include "components/bubble/bubble_controller.h" |
| 11 #include "components/bubble/bubble_manager_mocks.h" | 13 #include "components/bubble/bubble_manager_mocks.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 15 |
| 14 namespace { | 16 namespace { |
| 15 | 17 |
| 16 // A "show chain" happens when a bubble decides to show another bubble on close. | 18 // A "show chain" happens when a bubble decides to show another bubble on close. |
| 17 // All bubbles must be iterated to handle a close event. If a bubble shows | 19 // All bubbles must be iterated to handle a close event. If a bubble shows |
| 18 // another bubble while it's being closed, the iterator can get messed up. | 20 // another bubble while it's being closed, the iterator can get messed up. |
| 19 class ChainShowBubbleDelegate : public MockBubbleDelegate { | 21 class ChainShowBubbleDelegate : public MockBubbleDelegate { |
| 20 public: | 22 public: |
| 21 // |chained_bubble| can be nullptr if not interested in getting a reference to | 23 // |chained_bubble| can be nullptr if not interested in getting a reference to |
| 22 // the chained bubble. | 24 // the chained bubble. |
| 23 ChainShowBubbleDelegate(BubbleManager* manager, | 25 ChainShowBubbleDelegate(BubbleManager* manager, |
| 24 scoped_ptr<BubbleDelegate> delegate, | 26 std::unique_ptr<BubbleDelegate> delegate, |
| 25 BubbleReference* chained_bubble) | 27 BubbleReference* chained_bubble) |
| 26 : manager_(manager), | 28 : manager_(manager), |
| 27 delegate_(std::move(delegate)), | 29 delegate_(std::move(delegate)), |
| 28 chained_bubble_(chained_bubble), | 30 chained_bubble_(chained_bubble), |
| 29 closed_(false) { | 31 closed_(false) { |
| 30 EXPECT_CALL(*this, ShouldClose(testing::_)).WillOnce(testing::Return(true)); | 32 EXPECT_CALL(*this, ShouldClose(testing::_)).WillOnce(testing::Return(true)); |
| 31 } | 33 } |
| 32 | 34 |
| 33 ~ChainShowBubbleDelegate() override { EXPECT_TRUE(closed_); } | 35 ~ChainShowBubbleDelegate() override { EXPECT_TRUE(closed_); } |
| 34 | 36 |
| 35 void DidClose(BubbleCloseReason reason) override { | 37 void DidClose(BubbleCloseReason reason) override { |
| 36 MockBubbleDelegate::DidClose(reason); | 38 MockBubbleDelegate::DidClose(reason); |
| 37 BubbleReference ref = manager_->ShowBubble(std::move(delegate_)); | 39 BubbleReference ref = manager_->ShowBubble(std::move(delegate_)); |
| 38 if (chained_bubble_) | 40 if (chained_bubble_) |
| 39 *chained_bubble_ = ref; | 41 *chained_bubble_ = ref; |
| 40 closed_ = true; | 42 closed_ = true; |
| 41 } | 43 } |
| 42 | 44 |
| 43 private: | 45 private: |
| 44 BubbleManager* manager_; | 46 BubbleManager* manager_; |
| 45 scoped_ptr<BubbleDelegate> delegate_; | 47 std::unique_ptr<BubbleDelegate> delegate_; |
| 46 BubbleReference* chained_bubble_; | 48 BubbleReference* chained_bubble_; |
| 47 bool closed_; | 49 bool closed_; |
| 48 | 50 |
| 49 DISALLOW_COPY_AND_ASSIGN(ChainShowBubbleDelegate); | 51 DISALLOW_COPY_AND_ASSIGN(ChainShowBubbleDelegate); |
| 50 }; | 52 }; |
| 51 | 53 |
| 52 // A "close chain" happens when a close event is received while another close | 54 // A "close chain" happens when a close event is received while another close |
| 53 // event is in progress. Ex: Closing the BubbleUi will hide the bubble, causing | 55 // event is in progress. Ex: Closing the BubbleUi will hide the bubble, causing |
| 54 // it to lose focus, which causes another close event. This test simulates this | 56 // it to lose focus, which causes another close event. This test simulates this |
| 55 // by sending a close event during the |DidClose| method of a BubbleDelegate. | 57 // by sending a close event during the |DidClose| method of a BubbleDelegate. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 | 91 |
| 90 class BubbleManagerTest : public testing::Test { | 92 class BubbleManagerTest : public testing::Test { |
| 91 public: | 93 public: |
| 92 BubbleManagerTest(); | 94 BubbleManagerTest(); |
| 93 ~BubbleManagerTest() override {} | 95 ~BubbleManagerTest() override {} |
| 94 | 96 |
| 95 void SetUp() override; | 97 void SetUp() override; |
| 96 void TearDown() override; | 98 void TearDown() override; |
| 97 | 99 |
| 98 protected: | 100 protected: |
| 99 scoped_ptr<BubbleManagerSubclass> manager_; | 101 std::unique_ptr<BubbleManagerSubclass> manager_; |
| 100 | 102 |
| 101 private: | 103 private: |
| 102 DISALLOW_COPY_AND_ASSIGN(BubbleManagerTest); | 104 DISALLOW_COPY_AND_ASSIGN(BubbleManagerTest); |
| 103 }; | 105 }; |
| 104 | 106 |
| 105 BubbleManagerTest::BubbleManagerTest() {} | 107 BubbleManagerTest::BubbleManagerTest() {} |
| 106 | 108 |
| 107 void BubbleManagerTest::SetUp() { | 109 void BubbleManagerTest::SetUp() { |
| 108 testing::Test::SetUp(); | 110 testing::Test::SetUp(); |
| 109 manager_.reset(new BubbleManagerSubclass); | 111 manager_.reset(new BubbleManagerSubclass); |
| 110 } | 112 } |
| 111 | 113 |
| 112 void BubbleManagerTest::TearDown() { | 114 void BubbleManagerTest::TearDown() { |
| 113 manager_.reset(); | 115 manager_.reset(); |
| 114 testing::Test::TearDown(); | 116 testing::Test::TearDown(); |
| 115 } | 117 } |
| 116 | 118 |
| 117 TEST_F(BubbleManagerTest, ManagerShowsBubbleUi) { | 119 TEST_F(BubbleManagerTest, ManagerShowsBubbleUi) { |
| 118 scoped_ptr<MockBubbleDelegate> delegate = MockBubbleDelegate::Default(); | 120 std::unique_ptr<MockBubbleDelegate> delegate = MockBubbleDelegate::Default(); |
| 119 | 121 |
| 120 MockBubbleUi* bubble_ui = delegate->bubble_ui(); | 122 MockBubbleUi* bubble_ui = delegate->bubble_ui(); |
| 121 EXPECT_CALL(*bubble_ui, Destroyed()); | 123 EXPECT_CALL(*bubble_ui, Destroyed()); |
| 122 EXPECT_CALL(*bubble_ui, Show(testing::_)); | 124 EXPECT_CALL(*bubble_ui, Show(testing::_)); |
| 123 EXPECT_CALL(*bubble_ui, Close()); | 125 EXPECT_CALL(*bubble_ui, Close()); |
| 124 EXPECT_CALL(*bubble_ui, UpdateAnchorPosition()).Times(0); | 126 EXPECT_CALL(*bubble_ui, UpdateAnchorPosition()).Times(0); |
| 125 | 127 |
| 126 manager_->ShowBubble(std::move(delegate)); | 128 manager_->ShowBubble(std::move(delegate)); |
| 127 } | 129 } |
| 128 | 130 |
| 129 TEST_F(BubbleManagerTest, ManagerUpdatesBubbleUiAnchor) { | 131 TEST_F(BubbleManagerTest, ManagerUpdatesBubbleUiAnchor) { |
| 130 scoped_ptr<MockBubbleDelegate> delegate = MockBubbleDelegate::Default(); | 132 std::unique_ptr<MockBubbleDelegate> delegate = MockBubbleDelegate::Default(); |
| 131 | 133 |
| 132 MockBubbleUi* bubble_ui = delegate->bubble_ui(); | 134 MockBubbleUi* bubble_ui = delegate->bubble_ui(); |
| 133 EXPECT_CALL(*bubble_ui, Destroyed()); | 135 EXPECT_CALL(*bubble_ui, Destroyed()); |
| 134 EXPECT_CALL(*bubble_ui, Show(testing::_)); | 136 EXPECT_CALL(*bubble_ui, Show(testing::_)); |
| 135 EXPECT_CALL(*bubble_ui, Close()); | 137 EXPECT_CALL(*bubble_ui, Close()); |
| 136 EXPECT_CALL(*bubble_ui, UpdateAnchorPosition()); | 138 EXPECT_CALL(*bubble_ui, UpdateAnchorPosition()); |
| 137 | 139 |
| 138 manager_->ShowBubble(std::move(delegate)); | 140 manager_->ShowBubble(std::move(delegate)); |
| 139 manager_->UpdateAllBubbleAnchors(); | 141 manager_->UpdateAllBubbleAnchors(); |
| 140 } | 142 } |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 EXPECT_TRUE(ref3); | 255 EXPECT_TRUE(ref3); |
| 254 | 256 |
| 255 ref2->CloseBubble(BUBBLE_CLOSE_FOCUS_LOST); | 257 ref2->CloseBubble(BUBBLE_CLOSE_FOCUS_LOST); |
| 256 | 258 |
| 257 EXPECT_TRUE(ref1); | 259 EXPECT_TRUE(ref1); |
| 258 EXPECT_FALSE(ref2); | 260 EXPECT_FALSE(ref2); |
| 259 EXPECT_TRUE(ref3); | 261 EXPECT_TRUE(ref3); |
| 260 } | 262 } |
| 261 | 263 |
| 262 TEST_F(BubbleManagerTest, CloseOwnedByShouldLeaveUnowned) { | 264 TEST_F(BubbleManagerTest, CloseOwnedByShouldLeaveUnowned) { |
| 263 scoped_ptr<MockBubbleDelegate> delegate1 = MockBubbleDelegate::Default(); | 265 std::unique_ptr<MockBubbleDelegate> delegate1 = MockBubbleDelegate::Default(); |
| 264 scoped_ptr<MockBubbleDelegate> delegate2 = MockBubbleDelegate::Default(); | 266 std::unique_ptr<MockBubbleDelegate> delegate2 = MockBubbleDelegate::Default(); |
| 265 scoped_ptr<MockBubbleDelegate> delegate3 = MockBubbleDelegate::Default(); | 267 std::unique_ptr<MockBubbleDelegate> delegate3 = MockBubbleDelegate::Default(); |
| 266 MockBubbleDelegate& delegate1_ref = *delegate1; | 268 MockBubbleDelegate& delegate1_ref = *delegate1; |
| 267 MockBubbleDelegate& delegate2_ref = *delegate2; | 269 MockBubbleDelegate& delegate2_ref = *delegate2; |
| 268 MockBubbleDelegate& delegate3_ref = *delegate3; | 270 MockBubbleDelegate& delegate3_ref = *delegate3; |
| 269 BubbleReference ref1 = manager_->ShowBubble(std::move(delegate1)); | 271 BubbleReference ref1 = manager_->ShowBubble(std::move(delegate1)); |
| 270 BubbleReference ref2 = manager_->ShowBubble(std::move(delegate2)); | 272 BubbleReference ref2 = manager_->ShowBubble(std::move(delegate2)); |
| 271 BubbleReference ref3 = manager_->ShowBubble(std::move(delegate3)); | 273 BubbleReference ref3 = manager_->ShowBubble(std::move(delegate3)); |
| 272 | 274 |
| 273 // These pointers are only compared for equality, not dereferenced. | 275 // These pointers are only compared for equality, not dereferenced. |
| 274 const content::RenderFrameHost* const frame1 = | 276 const content::RenderFrameHost* const frame1 = |
| 275 reinterpret_cast<const content::RenderFrameHost*>(&ref1); | 277 reinterpret_cast<const content::RenderFrameHost*>(&ref1); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 | 315 |
| 314 // Bubble should NOT get a close event because it's already closed. | 316 // Bubble should NOT get a close event because it's already closed. |
| 315 manager_->CloseAllBubbles(BUBBLE_CLOSE_FOCUS_LOST); | 317 manager_->CloseAllBubbles(BUBBLE_CLOSE_FOCUS_LOST); |
| 316 } | 318 } |
| 317 | 319 |
| 318 // This test validates that it's possible to show another bubble when | 320 // This test validates that it's possible to show another bubble when |
| 319 // |CloseBubble| is called. | 321 // |CloseBubble| is called. |
| 320 TEST_F(BubbleManagerTest, AllowBubbleChainingOnClose) { | 322 TEST_F(BubbleManagerTest, AllowBubbleChainingOnClose) { |
| 321 BubbleReference chained_bubble; | 323 BubbleReference chained_bubble; |
| 322 BubbleReference ref = | 324 BubbleReference ref = |
| 323 manager_->ShowBubble(make_scoped_ptr(new ChainShowBubbleDelegate( | 325 manager_->ShowBubble(base::WrapUnique(new ChainShowBubbleDelegate( |
| 324 manager_.get(), MockBubbleDelegate::Default(), &chained_bubble))); | 326 manager_.get(), MockBubbleDelegate::Default(), &chained_bubble))); |
| 325 ASSERT_FALSE(chained_bubble); // Bubble not yet visible. | 327 ASSERT_FALSE(chained_bubble); // Bubble not yet visible. |
| 326 ASSERT_TRUE(manager_->CloseBubble(ref, BUBBLE_CLOSE_FORCED)); | 328 ASSERT_TRUE(manager_->CloseBubble(ref, BUBBLE_CLOSE_FORCED)); |
| 327 ASSERT_TRUE(chained_bubble); // Bubble is now visible. | 329 ASSERT_TRUE(chained_bubble); // Bubble is now visible. |
| 328 } | 330 } |
| 329 | 331 |
| 330 // This test validates that it's possible to show another bubble when | 332 // This test validates that it's possible to show another bubble when |
| 331 // |CloseAllBubbles| is called. | 333 // |CloseAllBubbles| is called. |
| 332 TEST_F(BubbleManagerTest, AllowBubbleChainingOnCloseAll) { | 334 TEST_F(BubbleManagerTest, AllowBubbleChainingOnCloseAll) { |
| 333 BubbleReference chained_bubble; | 335 BubbleReference chained_bubble; |
| 334 BubbleReference ref = | 336 BubbleReference ref = |
| 335 manager_->ShowBubble(make_scoped_ptr(new ChainShowBubbleDelegate( | 337 manager_->ShowBubble(base::WrapUnique(new ChainShowBubbleDelegate( |
| 336 manager_.get(), MockBubbleDelegate::Default(), &chained_bubble))); | 338 manager_.get(), MockBubbleDelegate::Default(), &chained_bubble))); |
| 337 ASSERT_FALSE(chained_bubble); // Bubble not yet visible. | 339 ASSERT_FALSE(chained_bubble); // Bubble not yet visible. |
| 338 manager_->CloseAllBubbles(BUBBLE_CLOSE_FORCED); | 340 manager_->CloseAllBubbles(BUBBLE_CLOSE_FORCED); |
| 339 ASSERT_TRUE(chained_bubble); // Bubble is now visible. | 341 ASSERT_TRUE(chained_bubble); // Bubble is now visible. |
| 340 } | 342 } |
| 341 | 343 |
| 342 // This test validates that a show chain will not happen in the destructor. | 344 // This test validates that a show chain will not happen in the destructor. |
| 343 // While chaining is during the normal life span of the manager, it should NOT | 345 // While chaining is during the normal life span of the manager, it should NOT |
| 344 // happen when the manager is being destroyed. | 346 // happen when the manager is being destroyed. |
| 345 TEST_F(BubbleManagerTest, BubblesDoNotChainOnDestroy) { | 347 TEST_F(BubbleManagerTest, BubblesDoNotChainOnDestroy) { |
| 346 MockBubbleManagerObserver metrics; | 348 MockBubbleManagerObserver metrics; |
| 347 // |chained_delegate| should never be shown. | 349 // |chained_delegate| should never be shown. |
| 348 EXPECT_CALL(metrics, OnBubbleNeverShown(testing::_)); | 350 EXPECT_CALL(metrics, OnBubbleNeverShown(testing::_)); |
| 349 // The ChainShowBubbleDelegate should be closed when the manager is destroyed. | 351 // The ChainShowBubbleDelegate should be closed when the manager is destroyed. |
| 350 EXPECT_CALL(metrics, OnBubbleClosed(testing::_, BUBBLE_CLOSE_FORCED)); | 352 EXPECT_CALL(metrics, OnBubbleClosed(testing::_, BUBBLE_CLOSE_FORCED)); |
| 351 manager_->AddBubbleManagerObserver(&metrics); | 353 manager_->AddBubbleManagerObserver(&metrics); |
| 352 | 354 |
| 353 scoped_ptr<MockBubbleDelegate> chained_delegate(new MockBubbleDelegate); | 355 std::unique_ptr<MockBubbleDelegate> chained_delegate(new MockBubbleDelegate); |
| 354 EXPECT_CALL(*chained_delegate->bubble_ui(), Show(testing::_)).Times(0); | 356 EXPECT_CALL(*chained_delegate->bubble_ui(), Show(testing::_)).Times(0); |
| 355 EXPECT_CALL(*chained_delegate, ShouldClose(testing::_)).Times(0); | 357 EXPECT_CALL(*chained_delegate, ShouldClose(testing::_)).Times(0); |
| 356 EXPECT_CALL(*chained_delegate, DidClose(testing::_)).Times(0); | 358 EXPECT_CALL(*chained_delegate, DidClose(testing::_)).Times(0); |
| 357 | 359 |
| 358 manager_->ShowBubble(make_scoped_ptr(new ChainShowBubbleDelegate( | 360 manager_->ShowBubble(base::WrapUnique(new ChainShowBubbleDelegate( |
| 359 manager_.get(), std::move(chained_delegate), nullptr))); | 361 manager_.get(), std::move(chained_delegate), nullptr))); |
| 360 manager_.reset(); | 362 manager_.reset(); |
| 361 } | 363 } |
| 362 | 364 |
| 363 TEST_F(BubbleManagerTest, BubbleCloseReasonIsCalled) { | 365 TEST_F(BubbleManagerTest, BubbleCloseReasonIsCalled) { |
| 364 MockBubbleManagerObserver metrics; | 366 MockBubbleManagerObserver metrics; |
| 365 EXPECT_CALL(metrics, OnBubbleNeverShown(testing::_)).Times(0); | 367 EXPECT_CALL(metrics, OnBubbleNeverShown(testing::_)).Times(0); |
| 366 EXPECT_CALL(metrics, OnBubbleClosed(testing::_, BUBBLE_CLOSE_ACCEPTED)); | 368 EXPECT_CALL(metrics, OnBubbleClosed(testing::_, BUBBLE_CLOSE_ACCEPTED)); |
| 367 manager_->AddBubbleManagerObserver(&metrics); | 369 manager_->AddBubbleManagerObserver(&metrics); |
| 368 | 370 |
| 369 BubbleReference ref = manager_->ShowBubble(MockBubbleDelegate::Default()); | 371 BubbleReference ref = manager_->ShowBubble(MockBubbleDelegate::Default()); |
| 370 ref->CloseBubble(BUBBLE_CLOSE_ACCEPTED); | 372 ref->CloseBubble(BUBBLE_CLOSE_ACCEPTED); |
| 371 | 373 |
| 372 // Destroy to verify no events are sent to |metrics| in destructor. | 374 // Destroy to verify no events are sent to |metrics| in destructor. |
| 373 manager_.reset(); | 375 manager_.reset(); |
| 374 } | 376 } |
| 375 | 377 |
| 376 // In a close chain, it should be possible for the bubble in the second close | 378 // In a close chain, it should be possible for the bubble in the second close |
| 377 // event to close. | 379 // event to close. |
| 378 TEST_F(BubbleManagerTest, BubbleCloseChainCloseClose) { | 380 TEST_F(BubbleManagerTest, BubbleCloseChainCloseClose) { |
| 379 scoped_ptr<ChainCloseBubbleDelegate> closing_bubble( | 381 std::unique_ptr<ChainCloseBubbleDelegate> closing_bubble( |
| 380 new ChainCloseBubbleDelegate(manager_.get())); | 382 new ChainCloseBubbleDelegate(manager_.get())); |
| 381 EXPECT_CALL(*closing_bubble, ShouldClose(testing::_)) | 383 EXPECT_CALL(*closing_bubble, ShouldClose(testing::_)) |
| 382 .WillOnce(testing::Return(true)); | 384 .WillOnce(testing::Return(true)); |
| 383 | 385 |
| 384 BubbleReference other_bubble_ref = | 386 BubbleReference other_bubble_ref = |
| 385 manager_->ShowBubble(MockBubbleDelegate::Default()); | 387 manager_->ShowBubble(MockBubbleDelegate::Default()); |
| 386 | 388 |
| 387 BubbleReference closing_bubble_ref = | 389 BubbleReference closing_bubble_ref = |
| 388 manager_->ShowBubble(std::move(closing_bubble)); | 390 manager_->ShowBubble(std::move(closing_bubble)); |
| 389 | 391 |
| 390 EXPECT_TRUE(other_bubble_ref); | 392 EXPECT_TRUE(other_bubble_ref); |
| 391 EXPECT_TRUE(closing_bubble_ref); | 393 EXPECT_TRUE(closing_bubble_ref); |
| 392 | 394 |
| 393 closing_bubble_ref->CloseBubble(BUBBLE_CLOSE_ACCEPTED); | 395 closing_bubble_ref->CloseBubble(BUBBLE_CLOSE_ACCEPTED); |
| 394 | 396 |
| 395 EXPECT_FALSE(other_bubble_ref); | 397 EXPECT_FALSE(other_bubble_ref); |
| 396 EXPECT_FALSE(closing_bubble_ref); | 398 EXPECT_FALSE(closing_bubble_ref); |
| 397 } | 399 } |
| 398 | 400 |
| 399 // In a close chain, it should be possible for the bubble in the second close | 401 // In a close chain, it should be possible for the bubble in the second close |
| 400 // event to remain open because close is a request. | 402 // event to remain open because close is a request. |
| 401 TEST_F(BubbleManagerTest, BubbleCloseChainCloseNoClose) { | 403 TEST_F(BubbleManagerTest, BubbleCloseChainCloseNoClose) { |
| 402 scoped_ptr<ChainCloseBubbleDelegate> closing_bubble( | 404 std::unique_ptr<ChainCloseBubbleDelegate> closing_bubble( |
| 403 new ChainCloseBubbleDelegate(manager_.get())); | 405 new ChainCloseBubbleDelegate(manager_.get())); |
| 404 EXPECT_CALL(*closing_bubble, ShouldClose(testing::_)) | 406 EXPECT_CALL(*closing_bubble, ShouldClose(testing::_)) |
| 405 .WillOnce(testing::Return(true)); | 407 .WillOnce(testing::Return(true)); |
| 406 | 408 |
| 407 BubbleReference other_bubble_ref = | 409 BubbleReference other_bubble_ref = |
| 408 manager_->ShowBubble(MockBubbleDelegate::Stubborn()); | 410 manager_->ShowBubble(MockBubbleDelegate::Stubborn()); |
| 409 | 411 |
| 410 BubbleReference closing_bubble_ref = | 412 BubbleReference closing_bubble_ref = |
| 411 manager_->ShowBubble(std::move(closing_bubble)); | 413 manager_->ShowBubble(std::move(closing_bubble)); |
| 412 | 414 |
| 413 EXPECT_TRUE(other_bubble_ref); | 415 EXPECT_TRUE(other_bubble_ref); |
| 414 EXPECT_TRUE(closing_bubble_ref); | 416 EXPECT_TRUE(closing_bubble_ref); |
| 415 | 417 |
| 416 closing_bubble_ref->CloseBubble(BUBBLE_CLOSE_ACCEPTED); | 418 closing_bubble_ref->CloseBubble(BUBBLE_CLOSE_ACCEPTED); |
| 417 | 419 |
| 418 EXPECT_TRUE(other_bubble_ref); | 420 EXPECT_TRUE(other_bubble_ref); |
| 419 EXPECT_FALSE(closing_bubble_ref); | 421 EXPECT_FALSE(closing_bubble_ref); |
| 420 } | 422 } |
| 421 | 423 |
| 422 // This test is a sanity check. |closing_bubble| will attempt to close all other | 424 // This test is a sanity check. |closing_bubble| will attempt to close all other |
| 423 // bubbles if it's closed, but it doesn't want to close. Sending a close request | 425 // bubbles if it's closed, but it doesn't want to close. Sending a close request |
| 424 // should keep it open without starting a close chain. | 426 // should keep it open without starting a close chain. |
| 425 TEST_F(BubbleManagerTest, BubbleCloseChainNoCloseNoClose) { | 427 TEST_F(BubbleManagerTest, BubbleCloseChainNoCloseNoClose) { |
| 426 scoped_ptr<ChainCloseBubbleDelegate> closing_bubble( | 428 std::unique_ptr<ChainCloseBubbleDelegate> closing_bubble( |
| 427 new ChainCloseBubbleDelegate(manager_.get())); | 429 new ChainCloseBubbleDelegate(manager_.get())); |
| 428 EXPECT_CALL(*closing_bubble, ShouldClose(testing::_)) | 430 EXPECT_CALL(*closing_bubble, ShouldClose(testing::_)) |
| 429 .WillRepeatedly(testing::Return(false)); | 431 .WillRepeatedly(testing::Return(false)); |
| 430 | 432 |
| 431 BubbleReference other_bubble_ref = | 433 BubbleReference other_bubble_ref = |
| 432 manager_->ShowBubble(MockBubbleDelegate::Default()); | 434 manager_->ShowBubble(MockBubbleDelegate::Default()); |
| 433 | 435 |
| 434 BubbleReference closing_bubble_ref = | 436 BubbleReference closing_bubble_ref = |
| 435 manager_->ShowBubble(std::move(closing_bubble)); | 437 manager_->ShowBubble(std::move(closing_bubble)); |
| 436 | 438 |
| 437 EXPECT_TRUE(other_bubble_ref); | 439 EXPECT_TRUE(other_bubble_ref); |
| 438 EXPECT_TRUE(closing_bubble_ref); | 440 EXPECT_TRUE(closing_bubble_ref); |
| 439 | 441 |
| 440 closing_bubble_ref->CloseBubble(BUBBLE_CLOSE_ACCEPTED); | 442 closing_bubble_ref->CloseBubble(BUBBLE_CLOSE_ACCEPTED); |
| 441 | 443 |
| 442 EXPECT_TRUE(other_bubble_ref); | 444 EXPECT_TRUE(other_bubble_ref); |
| 443 EXPECT_TRUE(closing_bubble_ref); | 445 EXPECT_TRUE(closing_bubble_ref); |
| 444 } | 446 } |
| 445 | 447 |
| 446 } // namespace | 448 } // namespace |
| OLD | NEW |