Skip to content

Commit

Permalink
CrOSSharingHub: Run Lacros browser test with Ash
Browse files Browse the repository at this point in the history
The Lacros test SharingHubBubbleControllerChromeOsBrowserTest
now runs as part of lacros_chrome_browsertests_run_in_series.

The test waits for the bubble to be shown and closed.

Previously, the tests were being skipped as Ash was not running.

Bug: 1300325
Change-Id: I095f415c14d0bed46dbd72cb8a92e9726eaa3727
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4111483
Reviewed-by: Travis Skare <skare@chromium.org>
Commit-Queue: Eric Willigers <ericwilligers@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1084874}
  • Loading branch information
ericwilligers authored and Chromium LUCI CQ committed Dec 19, 2022
1 parent b96911d commit 4f45215
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 10 deletions.
Expand Up @@ -2,6 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <string>
#include <utility>

#include "base/one_shot_event.h"
#include "base/run_loop.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/lacros/window_utility.h"
#include "chrome/browser/ui/page_action/page_action_icon_type.h"
Expand All @@ -26,28 +31,45 @@ class FakeSharesheet : public crosapi::mojom::Sharesheet {
FakeSharesheet& operator=(const FakeSharesheet&) = delete;
~FakeSharesheet() override = default;

void AwaitShow() {
base::RunLoop run_loop;
show_bubble_called_.Post(FROM_HERE, run_loop.QuitClosure());
run_loop.Run();
}

void AwaitClose() {
base::RunLoop run_loop;
close_bubble_called_.Post(FROM_HERE, run_loop.QuitClosure());
run_loop.Run();
}

private:
// crosapi::mojom::Sharesheet:
void ShowBubble(
const std::string& window_id,
sharesheet::LaunchSource source,
crosapi::mojom::IntentPtr intent,
crosapi::mojom::Sharesheet::ShowBubbleCallback callback) override {}
crosapi::mojom::Sharesheet::ShowBubbleCallback callback) override {
NOTREACHED();
}
void ShowBubbleWithOnClosed(
const std::string& window_id,
sharesheet::LaunchSource source,
crosapi::mojom::IntentPtr intent,
crosapi::mojom::Sharesheet::ShowBubbleWithOnClosedCallback callback)
override {
show_bubble_called = true;
show_bubble_called_.Signal();
callback_ = std::move(callback);
}
void CloseBubble(const std::string& window_id) override {
close_bubble_called = true;
close_bubble_called_.Signal();
std::move(callback_).Run();
}

public:
bool show_bubble_called = false;
bool close_bubble_called = false;
base::OneShotEvent show_bubble_called_;
base::OneShotEvent close_bubble_called_;
crosapi::mojom::Sharesheet::ShowBubbleWithOnClosedCallback callback_;
};

class SharingHubBubbleControllerChromeOsBrowserTest
Expand Down Expand Up @@ -96,16 +118,16 @@ IN_PROC_BROWSER_TEST_F(SharingHubBubbleControllerChromeOsBrowserTest,
CreateOrGetFromWebContents(web_contents)
->ShowBubble(share::ShareAttempt(web_contents));

// Verify that the sharesheet was opened.
EXPECT_TRUE(service_.show_bubble_called);
// Verify that the sharesheet is opened.
service_.AwaitShow();

// Close the sharesheet using the sharing hub controller.
sharing_hub::SharingHubBubbleControllerChromeOsImpl::
CreateOrGetFromWebContents(web_contents)
->HideBubble();

// Verify that the sharesheet was closed.
EXPECT_TRUE(service_.close_bubble_called);
// Verify that the sharesheet is closed.
service_.AwaitClose();
}

} // namespace
2 changes: 1 addition & 1 deletion chrome/test/BUILD.gn
Expand Up @@ -2759,7 +2759,6 @@ if (!is_android) {
"../browser/lacros/lacros_extension_apps_controller_browsertest.cc",
"../browser/lacros/lacros_extension_apps_publisher_browsertest.cc",
"../browser/policy/restricted_mgs_policy_provider_lacros_browsertest.cc",
"../browser/ui/sharing_hub/sharing_hub_bubble_controller_chromeos_lacros_browsertest.cc",
"../browser/web_applications/app_service/lacros_web_apps_controller_browsertest.cc",
]
deps += [
Expand Down Expand Up @@ -4921,6 +4920,7 @@ if (is_chromeos_lacros) {
"../browser/ui/browser_navigator_browsertest.cc",
"../browser/ui/browser_navigator_browsertest.h",
"../browser/ui/browser_navigator_browsertest_chromeos.cc",
"../browser/ui/sharing_hub/sharing_hub_bubble_controller_chromeos_lacros_browsertest.cc",
"../browser/ui/startup/first_run_service_browsertest.cc",
"../browser/ui/views/intent_picker_bubble_view_browsertest.cc",
"../browser/ui/views/location_bar/intent_chip_button_browsertest.cc",
Expand Down

0 comments on commit 4f45215

Please sign in to comment.