Commit 83d54946 authored by Eric Willigers's avatar Eric Willigers Committed by Commit Bot

WebTimeLimitEnforcerThrottleTest supports web apps

WebTimeLimitEnforcerThrottleTest::InstallAndLaunchWebApp now
uses web_app::InstallWebApp instead of relying on the old
Extensions implementation of web apps.

Bug: 1052722
Change-Id: I17ffa29c1204bcc81961e2f3c7f2ac1ffdd4fd7d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2065771
Commit-Queue: Eric Willigers <ericwilligers@chromium.org>
Reviewed-by: default avatarAga Wronska <agawronska@chromium.org>
Reviewed-by: default avatarAlexey Baskakov <loyso@chromium.org>
Cr-Commit-Position: refs/heads/master@{#742929}
parent 69fb4d08
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
#include <algorithm> #include <algorithm>
#include <memory>
#include <set> #include <set>
#include "base/feature_list.h" #include "base/feature_list.h"
...@@ -19,10 +20,11 @@ ...@@ -19,10 +20,11 @@
#include "chrome/browser/chromeos/login/test/user_policy_mixin.h" #include "chrome/browser/chromeos/login/test/user_policy_mixin.h"
#include "chrome/browser/chromeos/policy/user_policy_test_helper.h" #include "chrome/browser/chromeos/policy/user_policy_test_helper.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h" #include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/extensions/browsertest_util.h"
#include "chrome/browser/supervised_user/logged_in_user_mixin.h" #include "chrome/browser/supervised_user/logged_in_user_mixin.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_navigator_params.h" #include "chrome/browser/ui/browser_navigator_params.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/web_applications/test/web_app_browsertest_util.h"
#include "chrome/common/chrome_features.h" #include "chrome/common/chrome_features.h"
#include "chrome/common/web_application_info.h" #include "chrome/common/web_application_info.h"
#include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/in_process_browser_test.h"
...@@ -33,7 +35,6 @@ ...@@ -33,7 +35,6 @@
#include "content/public/browser/navigation_handle.h" #include "content/public/browser/navigation_handle.h"
#include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "extensions/common/extension.h"
#include "net/dns/mock_host_resolver.h" #include "net/dns/mock_host_resolver.h"
#include "ui/base/window_open_disposition.h" #include "ui/base/window_open_disposition.h"
#include "url/gurl.h" #include "url/gurl.h"
...@@ -180,30 +181,24 @@ WebTimeLimitEnforcerThrottleTest::GetWebTimeLimitEnforcer() { ...@@ -180,30 +181,24 @@ WebTimeLimitEnforcerThrottleTest::GetWebTimeLimitEnforcer() {
content::WebContents* WebTimeLimitEnforcerThrottleTest::InstallAndLaunchWebApp( content::WebContents* WebTimeLimitEnforcerThrottleTest::InstallAndLaunchWebApp(
const GURL& url, const GURL& url,
bool whitelisted_app) { bool whitelisted_app) {
WebApplicationInfo info; auto web_app_info = std::make_unique<WebApplicationInfo>();
info.title = base::UTF8ToUTF16(url.host()); web_app_info->title = base::UTF8ToUTF16(url.host());
info.description = base::UTF8ToUTF16("Web app"); web_app_info->description = base::UTF8ToUTF16("Web app");
info.app_url = url; web_app_info->app_url = url;
info.scope = url; web_app_info->scope = url;
info.open_as_window = true; web_app_info->open_as_window = true;
web_app::AppId app_id =
const extensions::Extension* extension = web_app::InstallWebApp(browser()->profile(), std::move(web_app_info));
extensions::browsertest_util::InstallBookmarkApp(browser()->profile(),
info); if (whitelisted_app)
EXPECT_TRUE(extension != nullptr); WhitelistApp(chromeos::app_time::AppId(apps::mojom::AppType::kWeb, app_id));
base::RunLoop().RunUntilIdle();
if (whitelisted_app) {
WhitelistApp(
chromeos::app_time::AppId(apps::mojom::AppType::kWeb, extension->id()));
}
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
auto* web_content = extensions::browsertest_util::AddTab(browser(), url); // Add a tab to |browser()| and return the newly added WebContents.
ui_test_utils::NavigateToURLWithDisposition(
return web_content; browser(), url, WindowOpenDisposition::NEW_FOREGROUND_TAB,
ui_test_utils::BROWSER_TEST_WAIT_FOR_LOAD_STOP);
return browser()->tab_strip_model()->GetActiveWebContents();
} }
void WebTimeLimitEnforcerThrottleTest::UpdatePolicy() { void WebTimeLimitEnforcerThrottleTest::UpdatePolicy() {
......
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