Skip to content

Commit

Permalink
[User Education] Migrate Tutorials to new API, remove old code
Browse files Browse the repository at this point in the history
This is a prerequisite to branching and conditional tutorials. We need
to consolidate on the API that will get these new enhancements.

There were several layers of entry points that could be used to build
tutorials previously; now there is only one that can be accessed by
teams building tutorials. Also, by consolidating on the new API, we
avoid examples of deprecated usage in the code.

Change-Id: I0032510bc901a6502149599a760f9b6502868d49
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4618067
Reviewed-by: Mickey Burks <mickeyburks@chromium.org>
Reviewed-by: David Black <dmblack@google.com>
Commit-Queue: Dana Fried <dfried@chromium.org>
Code-Coverage: Findit <findit-for-me@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/heads/main@{#1159183}
  • Loading branch information
Dana Fried authored and Chromium LUCI CQ committed Jun 16, 2023
1 parent 6f1d117 commit b091e6f
Show file tree
Hide file tree
Showing 13 changed files with 604 additions and 905 deletions.
24 changes: 12 additions & 12 deletions ash/user_education/welcome_tour/welcome_tour_controller_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ auto MoveArgs(T*... out) {
MATCHER_P(ElementSpecifierEq, element_specifier, "") {
return absl::visit(base::Overloaded{
[&](const ui::ElementIdentifier& element_id) {
return arg.element_id == element_id &&
arg.element_name.empty();
return arg.element_id() == element_id &&
arg.element_name().empty();
},
[&](const std::string& element_name) {
return arg.element_name == element_name &&
arg.element_id == ui::ElementIdentifier();
return arg.element_name() == element_name &&
arg.element_id() == ui::ElementIdentifier();
},
},
element_specifier);
Expand All @@ -93,23 +93,23 @@ MATCHER_P5(BubbleStep,
has_next_button,
"") {
namespace util = user_education_util;
return arg.step_type == ui::InteractionSequence::StepType::kShown &&
return arg.step_type() == ui::InteractionSequence::StepType::kShown &&
Matches(ElementSpecifierEq(element_specifier))(arg) &&
arg.context_mode == context_mode &&
util::GetHelpBubbleId(arg.extended_properties) == help_bubble_id &&
arg.body_text_id == body_text_id &&
arg.next_button_callback.is_null() != has_next_button;
arg.context_mode() == context_mode &&
util::GetHelpBubbleId(arg.extended_properties()) == help_bubble_id &&
arg.body_text_id() == body_text_id &&
arg.next_button_callback().is_null() != has_next_button;
}

MATCHER_P3(EventStep,
element_specifier,
context_mode,
has_name_elements_callback,
"") {
return arg.step_type == ui::InteractionSequence::StepType::kCustomEvent &&
return arg.step_type() == ui::InteractionSequence::StepType::kCustomEvent &&
Matches(ElementSpecifierEq(element_specifier))(arg) &&
arg.context_mode == context_mode &&
arg.name_elements_callback.is_null() != has_name_elements_callback;
arg.context_mode() == context_mode &&
arg.name_elements_callback().is_null() != has_name_elements_callback;
}

} // namespace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,8 @@ TEST_F(ChromeUserEducationDelegateTest, StartAndAbortTutorial) {
// Create a tutorial description.
user_education::TutorialDescription tutorial_description;
tutorial_description.steps.emplace_back(
/*title_text_id_=*/0, /*body_text_id_=*/IDS_OK,
ui::InteractionSequence::StepType::kShown, kElementId,
/*element_name=*/std::string(), user_education::HelpBubbleArrow::kNone);
user_education::TutorialDescription::BubbleStep(kElementId)
.SetBubbleBodyText(IDS_OK));

// Register the tutorial.
delegate()->RegisterTutorial(account_id(), ash::TutorialId::kTest,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,19 +121,15 @@ class BrowserFeaturePromoControllerTest : public TestWithBrowserView {
// Create a dummy tutorial.
// This is just the first two steps of the "create tab group" tutorial.
TutorialDescription desc;

TutorialDescription::Step step1(0, IDS_TUTORIAL_TAB_GROUP_ADD_TAB_TO_GROUP,
ui::InteractionSequence::StepType::kShown,
kTabStripElementId, std::string(),
HelpBubbleArrow::kTopCenter);
desc.steps.emplace_back(step1);

TutorialDescription::Step step2(
0, IDS_TUTORIAL_TAB_GROUP_ADD_TAB_TO_GROUP,
ui::InteractionSequence::StepType::kShown, kTabGroupEditorBubbleId,
std::string(), HelpBubbleArrow::kLeftCenter,
ui::CustomElementEventType(), false /*must_remain_visible*/);
desc.steps.emplace_back(std::move(step2));
desc.steps.emplace_back(
TutorialDescription::BubbleStep(kTabStripElementId)
.SetBubbleBodyText(IDS_TUTORIAL_TAB_GROUP_ADD_TAB_TO_GROUP)
.SetBubbleArrow(HelpBubbleArrow::kTopCenter));
desc.steps.emplace_back(
TutorialDescription::BubbleStep(kTabGroupEditorBubbleId)
.SetBubbleBodyText(IDS_TUTORIAL_TAB_GROUP_ADD_TAB_TO_GROUP)
.SetBubbleArrow(HelpBubbleArrow::kLeftCenter)
.AbortIfVisibilityLost(false));

user_education_service->tutorial_registry().AddTutorial(
kTestTutorialIdentifier, std::move(desc));
Expand Down

0 comments on commit b091e6f

Please sign in to comment.