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

Side by Side Diff: chrome/browser/ui/toolbar/toolbar_actions_bar_unittest.cc

Issue 1086973004: [Extensions Mac] Implement developer mode warning on mac (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Avi's Created 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/ui/toolbar/toolbar_actions_bar.h" 5 #include "chrome/browser/ui/toolbar/toolbar_actions_bar.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" 12 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h"
13 #include "chrome/browser/extensions/browser_action_test_util.h" 13 #include "chrome/browser/extensions/browser_action_test_util.h"
14 #include "chrome/browser/extensions/extension_action.h" 14 #include "chrome/browser/extensions/extension_action.h"
15 #include "chrome/browser/extensions/extension_action_manager.h" 15 #include "chrome/browser/extensions/extension_action_manager.h"
16 #include "chrome/browser/extensions/extension_action_test_util.h" 16 #include "chrome/browser/extensions/extension_action_test_util.h"
17 #include "chrome/browser/extensions/extension_service.h" 17 #include "chrome/browser/extensions/extension_service.h"
18 #include "chrome/browser/extensions/test_extension_system.h" 18 #include "chrome/browser/extensions/test_extension_system.h"
19 #include "chrome/browser/sessions/session_tab_helper.h" 19 #include "chrome/browser/sessions/session_tab_helper.h"
20 #include "chrome/browser/ui/extensions/extension_toolbar_icon_surfacing_bubble_d elegate.h"
20 #include "chrome/browser/ui/tabs/tab_strip_model.h" 21 #include "chrome/browser/ui/tabs/tab_strip_model.h"
21 #include "chrome/browser/ui/toolbar/test_toolbar_actions_bar_helper.h" 22 #include "chrome/browser/ui/toolbar/test_toolbar_actions_bar_helper.h"
22 #include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h" 23 #include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h"
23 #include "chrome/browser/ui/toolbar/toolbar_actions_bar_delegate.h" 24 #include "chrome/browser/ui/toolbar/toolbar_actions_bar_delegate.h"
24 #include "chrome/common/pref_names.h" 25 #include "chrome/common/pref_names.h"
25 #include "chrome/test/base/browser_with_test_window_test.h" 26 #include "chrome/test/base/browser_with_test_window_test.h"
26 #include "extensions/browser/extension_prefs.h" 27 #include "extensions/browser/extension_prefs.h"
27 #include "extensions/browser/extension_system.h" 28 #include "extensions/browser/extension_system.h"
28 #include "extensions/common/extension.h" 29 #include "extensions/common/extension.h"
29 #include "extensions/common/feature_switch.h" 30 #include "extensions/common/feature_switch.h"
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 ToolbarActionsBarRedesignUnitTest() : ToolbarActionsBarUnitTest(true) {} 427 ToolbarActionsBarRedesignUnitTest() : ToolbarActionsBarUnitTest(true) {}
427 ~ToolbarActionsBarRedesignUnitTest() override {} 428 ~ToolbarActionsBarRedesignUnitTest() override {}
428 429
429 private: 430 private:
430 DISALLOW_COPY_AND_ASSIGN(ToolbarActionsBarRedesignUnitTest); 431 DISALLOW_COPY_AND_ASSIGN(ToolbarActionsBarRedesignUnitTest);
431 }; 432 };
432 433
433 TEST_F(ToolbarActionsBarRedesignUnitTest, IconSurfacingBubbleAppearance) { 434 TEST_F(ToolbarActionsBarRedesignUnitTest, IconSurfacingBubbleAppearance) {
434 // Without showing anything new, we shouldn't show the bubble, and should 435 // Without showing anything new, we shouldn't show the bubble, and should
435 // auto-acknowledge it. 436 // auto-acknowledge it.
436 EXPECT_FALSE(toolbar_actions_bar()->ShouldShowInfoBubble()); 437 EXPECT_FALSE(
438 ExtensionToolbarIconSurfacingBubbleDelegate::ShouldShowForProfile(
439 profile()));
437 PrefService* prefs = profile()->GetPrefs(); 440 PrefService* prefs = profile()->GetPrefs();
438 EXPECT_TRUE( 441 EXPECT_TRUE(
439 prefs->GetBoolean(prefs::kToolbarIconSurfacingBubbleAcknowledged)); 442 prefs->GetBoolean(prefs::kToolbarIconSurfacingBubbleAcknowledged));
440 443
441 // Clear the pref for testing, and add an extension that wouldn't normally 444 // Clear the pref for testing, and add an extension that wouldn't normally
442 // have an icon. We should now show the bubble. 445 // have an icon. We should now show the bubble.
443 prefs->ClearPref(prefs::kToolbarIconSurfacingBubbleAcknowledged); 446 prefs->ClearPref(prefs::kToolbarIconSurfacingBubbleAcknowledged);
444 CreateAndAddExtension("extension", 447 CreateAndAddExtension("extension",
445 extensions::extension_action_test_util::NO_ACTION); 448 extensions::extension_action_test_util::NO_ACTION);
446 EXPECT_TRUE(toolbar_actions_bar()->ShouldShowInfoBubble()); 449 EXPECT_TRUE(ExtensionToolbarIconSurfacingBubbleDelegate::ShouldShowForProfile(
450 profile()));
447 451
448 // If the bubble was recently shown, we shouldn't show it again... 452 // If the bubble was recently shown, we shouldn't show it again...
449 ToolbarActionsBarBubbleDelegate* bubble_delegate = 453 scoped_ptr<ToolbarActionsBarBubbleDelegate> bubble_delegate(
450 static_cast<ToolbarActionsBarBubbleDelegate*>(toolbar_actions_bar()); 454 new ExtensionToolbarIconSurfacingBubbleDelegate(profile()));
451 bubble_delegate->OnToolbarActionsBarBubbleShown(); 455 bubble_delegate->OnBubbleShown();
452 bubble_delegate->OnToolbarActionsBarBubbleClosed( 456 bubble_delegate->OnBubbleClosed(
453 ToolbarActionsBarBubbleDelegate::DISMISSED); 457 ToolbarActionsBarBubbleDelegate::CLOSE_DISMISS);
454 EXPECT_FALSE(toolbar_actions_bar()->ShouldShowInfoBubble()); 458 EXPECT_FALSE(
459 ExtensionToolbarIconSurfacingBubbleDelegate::ShouldShowForProfile(
460 profile()));
455 461
456 // ...But if it was only dismissed, we should show it before too long. 462 // ...But if it was only dismissed, we should show it before too long.
457 base::Time two_days_ago = base::Time::Now() - base::TimeDelta::FromDays(2); 463 base::Time two_days_ago = base::Time::Now() - base::TimeDelta::FromDays(2);
458 prefs->SetInt64(prefs::kToolbarIconSurfacingBubbleLastShowTime, 464 prefs->SetInt64(prefs::kToolbarIconSurfacingBubbleLastShowTime,
459 two_days_ago.ToInternalValue()); 465 two_days_ago.ToInternalValue());
460 EXPECT_TRUE(toolbar_actions_bar()->ShouldShowInfoBubble()); 466 EXPECT_TRUE(ExtensionToolbarIconSurfacingBubbleDelegate::ShouldShowForProfile(
467 profile()));
461 468
462 // If it's acknowledged, then it should never show again, and should be 469 // If it's acknowledged, then it should never show again, and should be
463 // recorded as acknowledged. 470 // recorded as acknowledged.
464 bubble_delegate->OnToolbarActionsBarBubbleShown(); 471 bubble_delegate->OnBubbleShown();
465 bubble_delegate->OnToolbarActionsBarBubbleClosed( 472 bubble_delegate->OnBubbleClosed(
466 ToolbarActionsBarBubbleDelegate::ACKNOWLEDGED); 473 ToolbarActionsBarBubbleDelegate::CLOSE_EXECUTE);
467 EXPECT_FALSE(toolbar_actions_bar()->ShouldShowInfoBubble()); 474 EXPECT_FALSE(
475 ExtensionToolbarIconSurfacingBubbleDelegate::ShouldShowForProfile(
476 profile()));
468 base::Time one_week_ago = base::Time::Now() - base::TimeDelta::FromDays(7); 477 base::Time one_week_ago = base::Time::Now() - base::TimeDelta::FromDays(7);
469 prefs->SetInt64(prefs::kToolbarIconSurfacingBubbleLastShowTime, 478 prefs->SetInt64(prefs::kToolbarIconSurfacingBubbleLastShowTime,
470 one_week_ago.ToInternalValue()); 479 one_week_ago.ToInternalValue());
471 EXPECT_TRUE( 480 EXPECT_TRUE(
472 prefs->GetBoolean(prefs::kToolbarIconSurfacingBubbleAcknowledged)); 481 prefs->GetBoolean(prefs::kToolbarIconSurfacingBubbleAcknowledged));
473 } 482 }
474 483
475 class ToolbarActionsBarPopOutUnitTest 484 class ToolbarActionsBarPopOutUnitTest
476 : public ToolbarActionsBarRedesignUnitTest { 485 : public ToolbarActionsBarRedesignUnitTest {
477 public: 486 public:
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 EXPECT_TRUE(VerifyToolbarOrder(expected_names, 3u, 3u)); 773 EXPECT_TRUE(VerifyToolbarOrder(expected_names, 3u, 3u));
765 // Move "page action" to the overflow menu. 774 // Move "page action" to the overflow menu.
766 toolbar_actions_bar()->OnDragDrop( 775 toolbar_actions_bar()->OnDragDrop(
767 0, 2, ToolbarActionsBar::DRAG_TO_OVERFLOW); 776 0, 2, ToolbarActionsBar::DRAG_TO_OVERFLOW);
768 const char* expected_names2[] = { kBrowserAction, kSynthetic, kPageAction }; 777 const char* expected_names2[] = { kBrowserAction, kSynthetic, kPageAction };
769 EXPECT_TRUE(VerifyToolbarOrder(expected_names2, 3u, 2u)); 778 EXPECT_TRUE(VerifyToolbarOrder(expected_names2, 3u, 2u));
770 SetActionWantsToRunOnTab(action, web_contents, false); 779 SetActionWantsToRunOnTab(action, web_contents, false);
771 EXPECT_TRUE(VerifyToolbarOrder(expected_names2, 3u, 2u)); 780 EXPECT_TRUE(VerifyToolbarOrder(expected_names2, 3u, 2u));
772 } 781 }
773 } 782 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698