| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "base/bind_helpers.h" |
| 5 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 6 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
| 7 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 9 #include "base/values.h" | 10 #include "base/values.h" |
| 10 #include "chrome/browser/extensions/dev_mode_bubble_delegate.h" | 11 #include "chrome/browser/extensions/dev_mode_bubble_delegate.h" |
| 11 #include "chrome/browser/extensions/extension_function_test_utils.h" | 12 #include "chrome/browser/extensions/extension_function_test_utils.h" |
| 12 #include "chrome/browser/extensions/extension_service.h" | 13 #include "chrome/browser/extensions/extension_service.h" |
| 13 #include "chrome/browser/extensions/ntp_overridden_bubble_delegate.h" | 14 #include "chrome/browser/extensions/ntp_overridden_bubble_delegate.h" |
| 14 #include "chrome/browser/extensions/proxy_overridden_bubble_delegate.h" | 15 #include "chrome/browser/extensions/proxy_overridden_bubble_delegate.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 action_button_callback_count_(0), | 53 action_button_callback_count_(0), |
| 53 dismiss_button_callback_count_(0), | 54 dismiss_button_callback_count_(0), |
| 54 link_click_callback_count_(0) {} | 55 link_click_callback_count_(0) {} |
| 55 ~TestExtensionMessageBubbleController() override {} | 56 ~TestExtensionMessageBubbleController() override {} |
| 56 | 57 |
| 57 // ExtensionMessageBubbleController: | 58 // ExtensionMessageBubbleController: |
| 58 void OnBubbleAction() override { | 59 void OnBubbleAction() override { |
| 59 ++action_button_callback_count_; | 60 ++action_button_callback_count_; |
| 60 ExtensionMessageBubbleController::OnBubbleAction(); | 61 ExtensionMessageBubbleController::OnBubbleAction(); |
| 61 } | 62 } |
| 62 void OnBubbleDismiss() override { | 63 void OnBubbleDismiss(bool by_deactivation) override { |
| 63 ++dismiss_button_callback_count_; | 64 ++dismiss_button_callback_count_; |
| 64 ExtensionMessageBubbleController::OnBubbleDismiss(); | 65 ExtensionMessageBubbleController::OnBubbleDismiss(by_deactivation); |
| 65 } | 66 } |
| 66 void OnLinkClicked() override { | 67 void OnLinkClicked() override { |
| 67 ++link_click_callback_count_; | 68 ++link_click_callback_count_; |
| 68 ExtensionMessageBubbleController::OnLinkClicked(); | 69 ExtensionMessageBubbleController::OnLinkClicked(); |
| 69 } | 70 } |
| 70 | 71 |
| 71 size_t action_click_count() { return action_button_callback_count_; } | 72 size_t action_click_count() { return action_button_callback_count_; } |
| 72 size_t dismiss_click_count() { return dismiss_button_callback_count_; } | 73 size_t dismiss_click_count() { return dismiss_button_callback_count_; } |
| 73 size_t link_click_count() { return link_click_callback_count_; } | 74 size_t link_click_count() { return link_click_callback_count_; } |
| 74 | 75 |
| 75 private: | 76 private: |
| 76 // How often each button has been called. | 77 // How often each button has been called. |
| 77 size_t action_button_callback_count_; | 78 size_t action_button_callback_count_; |
| 78 size_t dismiss_button_callback_count_; | 79 size_t dismiss_button_callback_count_; |
| 79 size_t link_click_callback_count_; | 80 size_t link_click_callback_count_; |
| 80 | 81 |
| 81 DISALLOW_COPY_AND_ASSIGN(TestExtensionMessageBubbleController); | 82 DISALLOW_COPY_AND_ASSIGN(TestExtensionMessageBubbleController); |
| 82 }; | 83 }; |
| 83 | 84 |
| 84 // A fake bubble used for testing the controller. Takes an action that specifies | 85 // A fake bubble used for testing the controller. Takes an action that specifies |
| 85 // what should happen when the bubble is "shown" (the bubble is actually not | 86 // what should happen when the bubble is "shown" (the bubble is actually not |
| 86 // shown, the corresponding action is taken immediately). | 87 // shown, the corresponding action is taken immediately). |
| 87 class FakeExtensionMessageBubble { | 88 class FakeExtensionMessageBubble { |
| 88 public: | 89 public: |
| 89 enum ExtensionBubbleAction { | 90 enum ExtensionBubbleAction { |
| 90 BUBBLE_ACTION_CLICK_ACTION_BUTTON = 0, | 91 BUBBLE_ACTION_CLICK_ACTION_BUTTON = 0, |
| 91 BUBBLE_ACTION_CLICK_DISMISS_BUTTON, | 92 BUBBLE_ACTION_CLICK_DISMISS_BUTTON, |
| 93 BUBBLE_ACTION_DISMISS_DEACTIVATION, |
| 92 BUBBLE_ACTION_CLICK_LINK, | 94 BUBBLE_ACTION_CLICK_LINK, |
| 93 }; | 95 }; |
| 94 | 96 |
| 95 FakeExtensionMessageBubble() : controller_(nullptr) {} | 97 FakeExtensionMessageBubble() |
| 98 : action_(BUBBLE_ACTION_CLICK_ACTION_BUTTON), controller_(nullptr) {} |
| 96 | 99 |
| 97 void set_action_on_show(ExtensionBubbleAction action) { | 100 void set_action_on_show(ExtensionBubbleAction action) { |
| 98 action_ = action; | 101 action_ = action; |
| 99 } | 102 } |
| 100 void set_controller(ExtensionMessageBubbleController* controller) { | 103 void set_controller(ExtensionMessageBubbleController* controller) { |
| 101 controller_ = controller; | 104 controller_ = controller; |
| 102 } | 105 } |
| 103 | 106 |
| 104 void Show() { | 107 void Show() { |
| 105 controller_->OnShown(); | 108 controller_->OnShown(); |
| 106 if (action_ == BUBBLE_ACTION_CLICK_ACTION_BUTTON) | 109 switch (action_) { |
| 107 controller_->OnBubbleAction(); | 110 case BUBBLE_ACTION_CLICK_ACTION_BUTTON: |
| 108 else if (action_ == BUBBLE_ACTION_CLICK_DISMISS_BUTTON) | 111 controller_->OnBubbleAction(); |
| 109 controller_->OnBubbleDismiss(); | 112 break; |
| 110 else if (action_ == BUBBLE_ACTION_CLICK_LINK) | 113 case BUBBLE_ACTION_CLICK_DISMISS_BUTTON: |
| 111 controller_->OnLinkClicked(); | 114 controller_->OnBubbleDismiss(false); |
| 115 break; |
| 116 case BUBBLE_ACTION_DISMISS_DEACTIVATION: |
| 117 controller_->OnBubbleDismiss(true); |
| 118 break; |
| 119 case BUBBLE_ACTION_CLICK_LINK: |
| 120 controller_->OnLinkClicked(); |
| 121 break; |
| 122 } |
| 112 } | 123 } |
| 113 | 124 |
| 114 private: | 125 private: |
| 115 ExtensionBubbleAction action_; | 126 ExtensionBubbleAction action_; |
| 116 ExtensionMessageBubbleController* controller_; | 127 ExtensionMessageBubbleController* controller_; |
| 117 | 128 |
| 118 DISALLOW_COPY_AND_ASSIGN(FakeExtensionMessageBubble); | 129 DISALLOW_COPY_AND_ASSIGN(FakeExtensionMessageBubble); |
| 119 }; | 130 }; |
| 120 | 131 |
| 121 class ExtensionMessageBubbleTest : public BrowserWithTestWindowTest { | 132 class ExtensionMessageBubbleTest : public BrowserWithTestWindowTest { |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 } | 309 } |
| 299 | 310 |
| 300 ExtensionService* service_; | 311 ExtensionService* service_; |
| 301 | 312 |
| 302 private: | 313 private: |
| 303 scoped_ptr<base::CommandLine> command_line_; | 314 scoped_ptr<base::CommandLine> command_line_; |
| 304 | 315 |
| 305 DISALLOW_COPY_AND_ASSIGN(ExtensionMessageBubbleTest); | 316 DISALLOW_COPY_AND_ASSIGN(ExtensionMessageBubbleTest); |
| 306 }; | 317 }; |
| 307 | 318 |
| 319 TEST_F(ExtensionMessageBubbleTest, BubbleReshowsOnDeactivationDismissal) { |
| 320 Init(); |
| 321 |
| 322 ASSERT_TRUE(LoadExtensionOverridingNtp("1", kId1, Manifest::INTERNAL)); |
| 323 ASSERT_TRUE(LoadExtensionOverridingNtp("2", kId2, Manifest::INTERNAL)); |
| 324 scoped_ptr<TestExtensionMessageBubbleController> controller( |
| 325 new TestExtensionMessageBubbleController( |
| 326 new NtpOverriddenBubbleDelegate(browser()->profile()), browser())); |
| 327 |
| 328 // The list will contain one enabled unpacked extension (ext 2). |
| 329 EXPECT_TRUE(controller->ShouldShow()); |
| 330 std::vector<base::string16> override_extensions = |
| 331 controller->GetExtensionList(); |
| 332 ASSERT_EQ(1U, override_extensions.size()); |
| 333 EXPECT_EQ(base::ASCIIToUTF16("Extension 2"), override_extensions[0]); |
| 334 EXPECT_EQ(0U, controller->link_click_count()); |
| 335 EXPECT_EQ(0U, controller->dismiss_click_count()); |
| 336 EXPECT_EQ(0U, controller->action_click_count()); |
| 337 |
| 338 // Simulate showing the bubble and dismissing it due to deactivation. |
| 339 FakeExtensionMessageBubble bubble; |
| 340 bubble.set_action_on_show( |
| 341 FakeExtensionMessageBubble::BUBBLE_ACTION_DISMISS_DEACTIVATION); |
| 342 bubble.set_controller(controller.get()); |
| 343 bubble.Show(); |
| 344 EXPECT_EQ(0U, controller->link_click_count()); |
| 345 EXPECT_EQ(0U, controller->action_click_count()); |
| 346 EXPECT_EQ(1U, controller->dismiss_click_count()); |
| 347 |
| 348 // No extension should have become disabled. |
| 349 ExtensionRegistry* registry = ExtensionRegistry::Get(profile()); |
| 350 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId2)); |
| 351 // And since it was dismissed due to deactivation, the extension should not |
| 352 // have been acknowledged. |
| 353 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId2)); |
| 354 |
| 355 bubble.set_action_on_show( |
| 356 FakeExtensionMessageBubble::BUBBLE_ACTION_DISMISS_DEACTIVATION); |
| 357 controller.reset(new TestExtensionMessageBubbleController( |
| 358 new NtpOverriddenBubbleDelegate(browser()->profile()), browser())); |
| 359 // The bubble shouldn't show again for the same profile (we don't want to |
| 360 // be annoying). |
| 361 EXPECT_FALSE(controller->ShouldShow()); |
| 362 controller->ClearProfileListForTesting(); |
| 363 EXPECT_TRUE(controller->ShouldShow()); |
| 364 // Explicitly click the dismiss button. The extension should be acknowledged. |
| 365 bubble.set_controller(controller.get()); |
| 366 bubble.set_action_on_show( |
| 367 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_DISMISS_BUTTON); |
| 368 bubble.Show(); |
| 369 EXPECT_TRUE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId2)); |
| 370 |
| 371 // Uninstall the current ntp-controlling extension, allowing the other to |
| 372 // take control. |
| 373 service_->UninstallExtension(kId2, UNINSTALL_REASON_FOR_TESTING, |
| 374 base::Bind(&base::DoNothing), nullptr); |
| 375 |
| 376 // Even though we already showed for the given profile, we should show again, |
| 377 // because it's a different extension. |
| 378 controller.reset(new TestExtensionMessageBubbleController( |
| 379 new NtpOverriddenBubbleDelegate(browser()->profile()), browser())); |
| 380 EXPECT_TRUE(controller->ShouldShow()); |
| 381 } |
| 382 |
| 308 // The feature this is meant to test is only enacted on Windows, but it should | 383 // The feature this is meant to test is only enacted on Windows, but it should |
| 309 // pass on all platforms. | 384 // pass on all platforms. |
| 310 TEST_F(ExtensionMessageBubbleTest, WipeoutControllerTest) { | 385 TEST_F(ExtensionMessageBubbleTest, WipeoutControllerTest) { |
| 311 Init(); | 386 Init(); |
| 312 // Add three extensions, and control two of them in this test (extension 1 | 387 // Add three extensions, and control two of them in this test (extension 1 |
| 313 // and 2). | 388 // and 2). |
| 314 ASSERT_TRUE(LoadExtensionWithAction("1", kId1, Manifest::COMMAND_LINE)); | 389 ASSERT_TRUE(LoadExtensionWithAction("1", kId1, Manifest::COMMAND_LINE)); |
| 315 ASSERT_TRUE(LoadGenericExtension("2", kId2, Manifest::UNPACKED)); | 390 ASSERT_TRUE(LoadGenericExtension("2", kId2, Manifest::UNPACKED)); |
| 316 ASSERT_TRUE(LoadGenericExtension("3", kId3, Manifest::EXTERNAL_POLICY)); | 391 ASSERT_TRUE(LoadGenericExtension("3", kId3, Manifest::EXTERNAL_POLICY)); |
| 317 | 392 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 336 | 411 |
| 337 // Now disable an extension, specifying the wipeout flag. | 412 // Now disable an extension, specifying the wipeout flag. |
| 338 service_->DisableExtension(kId1, Extension::DISABLE_NOT_VERIFIED); | 413 service_->DisableExtension(kId1, Extension::DISABLE_NOT_VERIFIED); |
| 339 | 414 |
| 340 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1)); | 415 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1)); |
| 341 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId2)); | 416 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId2)); |
| 342 controller.reset( | 417 controller.reset( |
| 343 new TestExtensionMessageBubbleController( | 418 new TestExtensionMessageBubbleController( |
| 344 new SuspiciousExtensionBubbleDelegate(browser()->profile()), | 419 new SuspiciousExtensionBubbleDelegate(browser()->profile()), |
| 345 browser())); | 420 browser())); |
| 346 SuspiciousExtensionBubbleDelegate::ClearProfileListForTesting(); | 421 controller->ClearProfileListForTesting(); |
| 347 EXPECT_TRUE(controller->ShouldShow()); | 422 EXPECT_TRUE(controller->ShouldShow()); |
| 348 suspicious_extensions = controller->GetExtensionList(); | 423 suspicious_extensions = controller->GetExtensionList(); |
| 349 ASSERT_EQ(1U, suspicious_extensions.size()); | 424 ASSERT_EQ(1U, suspicious_extensions.size()); |
| 350 EXPECT_TRUE(base::ASCIIToUTF16("Extension 1") == suspicious_extensions[0]); | 425 EXPECT_TRUE(base::ASCIIToUTF16("Extension 1") == suspicious_extensions[0]); |
| 351 bubble.set_controller(controller.get()); | 426 bubble.set_controller(controller.get()); |
| 352 bubble.Show(); // Simulate showing the bubble. | 427 bubble.Show(); // Simulate showing the bubble. |
| 353 EXPECT_EQ(0U, controller->link_click_count()); | 428 EXPECT_EQ(0U, controller->link_click_count()); |
| 354 EXPECT_EQ(1U, controller->dismiss_click_count()); | 429 EXPECT_EQ(1U, controller->dismiss_click_count()); |
| 355 // Now the acknowledge flag should be set only for the first extension. | 430 // Now the acknowledge flag should be set only for the first extension. |
| 356 EXPECT_TRUE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1)); | 431 EXPECT_TRUE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1)); |
| 357 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId2)); | 432 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId2)); |
| 358 // Clear the flag. | 433 // Clear the flag. |
| 359 controller->delegate()->SetBubbleInfoBeenAcknowledged(kId1, false); | 434 controller->delegate()->SetBubbleInfoBeenAcknowledged(kId1, false); |
| 360 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1)); | 435 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1)); |
| 361 | 436 |
| 362 // Now disable the other extension and exercise the link click code path. | 437 // Now disable the other extension and exercise the link click code path. |
| 363 service_->DisableExtension(kId2, Extension::DISABLE_NOT_VERIFIED); | 438 service_->DisableExtension(kId2, Extension::DISABLE_NOT_VERIFIED); |
| 364 | 439 |
| 365 bubble.set_action_on_show( | 440 bubble.set_action_on_show( |
| 366 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_LINK); | 441 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_LINK); |
| 367 controller.reset( | 442 controller.reset( |
| 368 new TestExtensionMessageBubbleController( | 443 new TestExtensionMessageBubbleController( |
| 369 new SuspiciousExtensionBubbleDelegate(browser()->profile()), | 444 new SuspiciousExtensionBubbleDelegate(browser()->profile()), |
| 370 browser())); | 445 browser())); |
| 371 SuspiciousExtensionBubbleDelegate::ClearProfileListForTesting(); | 446 controller->ClearProfileListForTesting(); |
| 372 EXPECT_TRUE(controller->ShouldShow()); | 447 EXPECT_TRUE(controller->ShouldShow()); |
| 373 suspicious_extensions = controller->GetExtensionList(); | 448 suspicious_extensions = controller->GetExtensionList(); |
| 374 ASSERT_EQ(2U, suspicious_extensions.size()); | 449 ASSERT_EQ(2U, suspicious_extensions.size()); |
| 375 EXPECT_TRUE(base::ASCIIToUTF16("Extension 1") == suspicious_extensions[1]); | 450 EXPECT_TRUE(base::ASCIIToUTF16("Extension 1") == suspicious_extensions[1]); |
| 376 EXPECT_TRUE(base::ASCIIToUTF16("Extension 2") == suspicious_extensions[0]); | 451 EXPECT_TRUE(base::ASCIIToUTF16("Extension 2") == suspicious_extensions[0]); |
| 377 bubble.set_controller(controller.get()); | 452 bubble.set_controller(controller.get()); |
| 378 bubble.Show(); // Simulate showing the bubble. | 453 bubble.Show(); // Simulate showing the bubble. |
| 379 EXPECT_EQ(1U, controller->link_click_count()); | 454 EXPECT_EQ(1U, controller->link_click_count()); |
| 380 EXPECT_EQ(0U, controller->dismiss_click_count()); | 455 EXPECT_EQ(0U, controller->dismiss_click_count()); |
| 381 EXPECT_TRUE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1)); | 456 EXPECT_TRUE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1)); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL); | 498 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL); |
| 424 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId2) != NULL); | 499 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId2) != NULL); |
| 425 | 500 |
| 426 // Do it again, but now press different button (Disable). | 501 // Do it again, but now press different button (Disable). |
| 427 bubble.set_action_on_show( | 502 bubble.set_action_on_show( |
| 428 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_ACTION_BUTTON); | 503 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_ACTION_BUTTON); |
| 429 controller.reset( | 504 controller.reset( |
| 430 new TestExtensionMessageBubbleController( | 505 new TestExtensionMessageBubbleController( |
| 431 new DevModeBubbleDelegate(browser()->profile()), | 506 new DevModeBubbleDelegate(browser()->profile()), |
| 432 browser())); | 507 browser())); |
| 433 DevModeBubbleDelegate::ClearProfileListForTesting(); | 508 // Most bubbles would want to show again as long as the extensions weren't |
| 509 // acknowledged and the bubble wasn't dismissed due to deactivation. Since dev |
| 510 // mode extensions can't be (persistently) acknowledged, this isn't the case |
| 511 // for the dev mode bubble, and we should only show once per profile. |
| 512 EXPECT_FALSE(controller->ShouldShow()); |
| 513 controller->ClearProfileListForTesting(); |
| 434 EXPECT_TRUE(controller->ShouldShow()); | 514 EXPECT_TRUE(controller->ShouldShow()); |
| 435 dev_mode_extensions = controller->GetExtensionList(); | 515 dev_mode_extensions = controller->GetExtensionList(); |
| 436 EXPECT_EQ(2U, dev_mode_extensions.size()); | 516 EXPECT_EQ(2U, dev_mode_extensions.size()); |
| 437 bubble.set_controller(controller.get()); | 517 bubble.set_controller(controller.get()); |
| 438 bubble.Show(); // Simulate showing the bubble. | 518 bubble.Show(); // Simulate showing the bubble. |
| 439 EXPECT_EQ(0U, controller->link_click_count()); | 519 EXPECT_EQ(0U, controller->link_click_count()); |
| 440 EXPECT_EQ(1U, controller->action_click_count()); | 520 EXPECT_EQ(1U, controller->action_click_count()); |
| 441 EXPECT_EQ(0U, controller->dismiss_click_count()); | 521 EXPECT_EQ(0U, controller->dismiss_click_count()); |
| 442 EXPECT_TRUE(registry->disabled_extensions().GetByID(kId1) != NULL); | 522 EXPECT_TRUE(registry->disabled_extensions().GetByID(kId1) != NULL); |
| 443 EXPECT_TRUE(registry->disabled_extensions().GetByID(kId2) != NULL); | 523 EXPECT_TRUE(registry->disabled_extensions().GetByID(kId2) != NULL); |
| 444 | 524 |
| 445 // Re-enable the extensions (disabled by the action button above). | 525 // Re-enable the extensions (disabled by the action button above). |
| 446 service_->EnableExtension(kId1); | 526 service_->EnableExtension(kId1); |
| 447 service_->EnableExtension(kId2); | 527 service_->EnableExtension(kId2); |
| 448 | 528 |
| 449 // Show the dialog a third time, but now press the learn more link. | 529 // Show the dialog a third time, but now press the learn more link. |
| 450 bubble.set_action_on_show( | 530 bubble.set_action_on_show( |
| 451 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_LINK); | 531 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_LINK); |
| 452 controller.reset( | 532 controller.reset( |
| 453 new TestExtensionMessageBubbleController( | 533 new TestExtensionMessageBubbleController( |
| 454 new DevModeBubbleDelegate(browser()->profile()), | 534 new DevModeBubbleDelegate(browser()->profile()), |
| 455 browser())); | 535 browser())); |
| 456 DevModeBubbleDelegate::ClearProfileListForTesting(); | 536 controller->ClearProfileListForTesting(); |
| 457 EXPECT_TRUE(controller->ShouldShow()); | 537 EXPECT_TRUE(controller->ShouldShow()); |
| 458 dev_mode_extensions = controller->GetExtensionList(); | 538 dev_mode_extensions = controller->GetExtensionList(); |
| 459 EXPECT_EQ(2U, dev_mode_extensions.size()); | 539 EXPECT_EQ(2U, dev_mode_extensions.size()); |
| 460 bubble.set_controller(controller.get()); | 540 bubble.set_controller(controller.get()); |
| 461 bubble.Show(); // Simulate showing the bubble. | 541 bubble.Show(); // Simulate showing the bubble. |
| 462 EXPECT_EQ(1U, controller->link_click_count()); | 542 EXPECT_EQ(1U, controller->link_click_count()); |
| 463 EXPECT_EQ(0U, controller->action_click_count()); | 543 EXPECT_EQ(0U, controller->action_click_count()); |
| 464 EXPECT_EQ(0U, controller->dismiss_click_count()); | 544 EXPECT_EQ(0U, controller->dismiss_click_count()); |
| 465 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL); | 545 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL); |
| 466 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId2) != NULL); | 546 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId2) != NULL); |
| 467 | 547 |
| 468 // Now disable the unpacked extension. | 548 // Now disable the unpacked extension. |
| 469 service_->DisableExtension(kId1, Extension::DISABLE_USER_ACTION); | 549 service_->DisableExtension(kId1, Extension::DISABLE_USER_ACTION); |
| 470 service_->DisableExtension(kId2, Extension::DISABLE_USER_ACTION); | 550 service_->DisableExtension(kId2, Extension::DISABLE_USER_ACTION); |
| 471 | 551 |
| 472 controller.reset( | 552 controller.reset( |
| 473 new TestExtensionMessageBubbleController( | 553 new TestExtensionMessageBubbleController( |
| 474 new DevModeBubbleDelegate(browser()->profile()), | 554 new DevModeBubbleDelegate(browser()->profile()), |
| 475 browser())); | 555 browser())); |
| 476 DevModeBubbleDelegate::ClearProfileListForTesting(); | 556 controller->ClearProfileListForTesting(); |
| 477 EXPECT_FALSE(controller->ShouldShow()); | 557 EXPECT_FALSE(controller->ShouldShow()); |
| 478 dev_mode_extensions = controller->GetExtensionList(); | 558 dev_mode_extensions = controller->GetExtensionList(); |
| 479 EXPECT_EQ(0U, dev_mode_extensions.size()); | 559 EXPECT_EQ(0U, dev_mode_extensions.size()); |
| 480 } | 560 } |
| 481 | 561 |
| 482 // The feature this is meant to test is only implemented on Windows. | 562 // The feature this is meant to test is only implemented on Windows. |
| 483 #if defined(OS_WIN) | 563 #if defined(OS_WIN) |
| 484 #define MAYBE_SettingsApiControllerTest SettingsApiControllerTest | 564 #define MAYBE_SettingsApiControllerTest SettingsApiControllerTest |
| 485 #else | 565 #else |
| 486 #define MAYBE_SettingsApiControllerTest DISABLED_SettingsApiControllerTest | 566 #define MAYBE_SettingsApiControllerTest DISABLED_SettingsApiControllerTest |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 871 extensions::UNINSTALL_REASON_FOR_TESTING, | 951 extensions::UNINSTALL_REASON_FOR_TESTING, |
| 872 base::Bind(&base::DoNothing), | 952 base::Bind(&base::DoNothing), |
| 873 NULL); | 953 NULL); |
| 874 service_->UninstallExtension(kId3, | 954 service_->UninstallExtension(kId3, |
| 875 extensions::UNINSTALL_REASON_FOR_TESTING, | 955 extensions::UNINSTALL_REASON_FOR_TESTING, |
| 876 base::Bind(&base::DoNothing), | 956 base::Bind(&base::DoNothing), |
| 877 NULL); | 957 NULL); |
| 878 } | 958 } |
| 879 | 959 |
| 880 } // namespace extensions | 960 } // namespace extensions |
| OLD | NEW |