Skip to content

Commit

Permalink
[CSC] Add signin flow test
Browse files Browse the repository at this point in the history
1. If already signed in, skip the sign-in flow.
2. Also added an sync enum for the companion access point.

(cherry picked from commit 4ca4170)

Bug: b/280536741, crbug.com/1449021
Change-Id: I6eccdceab94c839925e3bc85a882f8c3846c6b82
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4546596
Commit-Queue: Shakti Sahu <shaktisahu@chromium.org>
Reviewed-by: Michael Crouse <mcrouse@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#1148182}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4582687
Cr-Commit-Position: refs/branch-heads/5790@{#235}
Cr-Branched-From: 1d71a33-refs/heads/main@{#1148114}
  • Loading branch information
Shakti Sahu authored and Chromium LUCI CQ committed Jun 1, 2023
1 parent 32fb5ad commit cfd6e01
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
Expand Up @@ -12,6 +12,7 @@
#include "base/test/bind.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "build/buildflag.h"
#include "chrome/browser/companion/core/companion_metrics_logger.h"
#include "chrome/browser/companion/core/constants.h"
#include "chrome/browser/companion/core/features.h"
Expand Down Expand Up @@ -749,6 +750,37 @@ IN_PROC_BROWSER_TEST_F(CompanionPageBrowserTest, ExpsPromoURLLoadsInNewTab) {
kExpectedExpsPromoUrl));
}

#if !BUILDFLAG(IS_CHROMEOS_ASH) && !BUILDFLAG(IS_CHROMEOS_LACROS)
IN_PROC_BROWSER_TEST_F(CompanionPageBrowserTest, SigninLoadsInNewTab) {
ukm::TestAutoSetUkmRecorder ukm_recorder;
// Load a page on the active tab.
ASSERT_TRUE(
ui_test_utils::NavigateToURL(browser(), CreateUrl(kHost, kRelativeUrl1)));
ASSERT_EQ(side_panel_coordinator()->GetCurrentEntryId(), absl::nullopt);

EXPECT_EQ(1, browser()->tab_strip_model()->count());

// Open companion companion via toolbar entry point.
side_panel_coordinator()->Show(SidePanelEntry::Id::kSearchCompanion);
EXPECT_TRUE(side_panel_coordinator()->IsSidePanelShowing());

WaitForCompanionToBeLoaded();
EXPECT_EQ(side_panel_coordinator()->GetCurrentEntryId(),
SidePanelEntry::Id::kSearchCompanion);

// Show sign-in promo, user accepts it.
CompanionScriptBuilder builder(MethodType::kOnPromoAction);
builder.promo_type = PromoType::kSignin;
builder.promo_action = PromoAction::kAccepted;
EXPECT_TRUE(ExecJs(builder.Build()));

// Verify that a new tab opens up to load the sign-in URL.
WaitForTabCount(2);
EXPECT_TRUE(web_contents()->GetVisibleURL().spec().starts_with(
"https://accounts.google.com/signin/chrome/sync"));
}
#endif

IN_PROC_BROWSER_TEST_F(CompanionPageBrowserTest, RegionSearchClick) {
ukm::TestAutoSetUkmRecorder ukm_recorder;

Expand Down
Expand Up @@ -46,6 +46,10 @@ bool SigninDelegateImpl::IsSignedIn() {
}

void SigninDelegateImpl::StartSigninFlow() {
if (IsSignedIn()) {
return;
}

DCHECK(AllowedSignin());

// Show the promo here.
Expand Down

0 comments on commit cfd6e01

Please sign in to comment.