Commit 5342b63a authored by Peter K. Lee's avatar Peter K. Lee Committed by Commit Bot

Fixed PopupMenuMediatorTest to account for Manual Translate option

This fixed unit test failures when Manual Translate is enabled by
default. This is required for http://crrev/c/1693506.

Change-Id: I462487633925de4c19f6a65ba986df3d96bb881b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1695654
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Auto-Submit: Peter Lee <pkl@chromium.org>
Cr-Commit-Position: refs/heads/master@{#676322}
parent c744edf1
...@@ -100,6 +100,7 @@ source_set("unit_tests") { ...@@ -100,6 +100,7 @@ source_set("unit_tests") {
"//components/feature_engagement/test:test_support", "//components/feature_engagement/test:test_support",
"//components/language/ios/browser", "//components/language/ios/browser",
"//components/reading_list/core", "//components/reading_list/core",
"//components/translate/core/browser",
"//ios/chrome/browser/browser_state:test_support", "//ios/chrome/browser/browser_state:test_support",
"//ios/chrome/browser/ui/popup_menu/cells", "//ios/chrome/browser/ui/popup_menu/cells",
"//ios/chrome/browser/ui/popup_menu/public:popup_menu_ui", "//ios/chrome/browser/ui/popup_menu/public:popup_menu_ui",
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "components/feature_engagement/test/mock_tracker.h" #include "components/feature_engagement/test/mock_tracker.h"
#include "components/language/ios/browser/ios_language_detection_tab_helper.h" #include "components/language/ios/browser/ios_language_detection_tab_helper.h"
#include "components/reading_list/core/reading_list_model_impl.h" #include "components/reading_list/core/reading_list_model_impl.h"
#include "components/translate/core/browser/translate_prefs.h"
#import "ios/chrome/browser/ui/popup_menu/cells/popup_menu_tools_item.h" #import "ios/chrome/browser/ui/popup_menu/cells/popup_menu_tools_item.h"
#import "ios/chrome/browser/ui/popup_menu/popup_menu_constants.h" #import "ios/chrome/browser/ui/popup_menu/popup_menu_constants.h"
#import "ios/chrome/browser/ui/popup_menu/public/popup_menu_table_view_controller.h" #import "ios/chrome/browser/ui/popup_menu/public/popup_menu_table_view_controller.h"
...@@ -190,35 +191,57 @@ TEST_F(PopupMenuMediatorTest, TestFeatureEngagementDisconnect) { ...@@ -190,35 +191,57 @@ TEST_F(PopupMenuMediatorTest, TestFeatureEngagementDisconnect) {
mediator_.popupMenu = popup_menu_; mediator_.popupMenu = popup_menu_;
mediator_.engagementTracker = &tracker; mediator_.engagementTracker = &tracker;
EXPECT_CALL(tracker, Dismissed(testing::_)); // There may be one or more Tools Menu items that use engagement trackers.
EXPECT_CALL(tracker, Dismissed(testing::_)).Times(testing::AtLeast(1));
[mediator_ disconnect]; [mediator_ disconnect];
} }
// Tests that the mediator is returning the right number of items and sections // Tests that the mediator is returning the right number of items and sections
// for the Tools Menu type. // for the Tools Menu type.
TEST_F(PopupMenuMediatorTest, TestElementsToolsMenu) { TEST_F(PopupMenuMediatorTest, TestToolsMenuItemsCount) {
CreateMediator(PopupMenuTypeToolsMenu, NO, NO); CreateMediator(PopupMenuTypeToolsMenu, NO, NO);
NSUInteger number_of_action_items = 6; NSUInteger number_of_action_items = 6;
if (base::FeatureList::IsEnabled(translate::kTranslateMobileManualTrigger)) {
number_of_action_items++;
}
if (ios::GetChromeBrowserProvider() if (ios::GetChromeBrowserProvider()
->GetUserFeedbackProvider() ->GetUserFeedbackProvider()
->IsUserFeedbackEnabled()) { ->IsUserFeedbackEnabled()) {
number_of_action_items++; number_of_action_items++;
} }
CheckMediatorSetItems(@[ @(3), @(5), @(number_of_action_items) ]); // Checks that Tools Menu has the right number of items in each section.
CheckMediatorSetItems(@[
// Stop/Reload, New Tab, New Incognito Tab
@(3),
// 4 collections + Settings
@(5),
// Other actions, depending on configuration
@(number_of_action_items)
]);
} }
// Tests that the mediator is returning the right number of items and sections // Tests that the mediator is returning the right number of items and sections
// for the Tab Grid type, in non-incognito. // for the Tab Grid type, in non-incognito.
TEST_F(PopupMenuMediatorTest, TestElementsTabGridNonIncognito) { TEST_F(PopupMenuMediatorTest, TestTabGridMenuNonIncognito) {
CreateMediator(PopupMenuTypeTabGrid, NO, NO); CreateMediator(PopupMenuTypeTabGrid, NO, NO);
CheckMediatorSetItems(@[ @(2), @(1) ]); CheckMediatorSetItems(@[
// New Tab, New Incognito Tab
@(2),
// Close Tab
@(1)
]);
} }
// Tests that the mediator is returning the right number of items and sections // Tests that the mediator is returning the right number of items and sections
// for the Tab Grid type, in incognito. // for the Tab Grid type, in incognito.
TEST_F(PopupMenuMediatorTest, TestElementsTabGridIncognito) { TEST_F(PopupMenuMediatorTest, TestTabGridMenuIncognito) {
CreateMediator(PopupMenuTypeTabGrid, YES, NO); CreateMediator(PopupMenuTypeTabGrid, YES, NO);
CheckMediatorSetItems(@[ @(2), @(1) ]); CheckMediatorSetItems(@[
// New Tab, New Incognito Tab
@(2),
// Close Tab
@(1)
]);
} }
// Tests that the mediator is asking for an item to be highlighted when asked. // Tests that the mediator is asking for an item to be highlighted when asked.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment