Commit 513902cd authored by Mitsuru Oshima's avatar Mitsuru Oshima Committed by Commit Bot

Fixes various ash_ui_perftests issues

* Fixed data dependency so that it builds necessary pak files.
* Quirks manager isn't available in this test.
* Do not run tasks in NetworkStateTestHelper setup, as it can run
  the tasks that should be run after setup.
* Set the host window bounds in AshContentTest::SetUp before
  initializing ash. AshTestHelper will set its own otherwise.
* Compute the test window size based on the display size.
  The current code uses fixed size and smaller than one used in
  interactive_ui_tests.

Change-Id: I20725e1e5ae6ca9b93af6538b11bebf02bd2485b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1722205
Commit-Queue: Mitsuru Oshima <oshima@chromium.org>
Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#682518}
parent 8b103f5d
......@@ -1573,6 +1573,11 @@ static_library("ash_shell_lib_with_content") {
public_deps = [
":ash_shell_lib",
]
data_deps = [
"//ash/strings:ash_test_strings",
"//ash/resources:ash_test_resources_with_content_100_percent",
"//ash/resources:ash_test_resources_200_percent",
]
}
copy("dbus_service_files") {
......@@ -2112,10 +2117,6 @@ executable("ash_shell_with_content") {
"//content/public/app:both",
"//device/bluetooth",
]
data_deps = [
"//ash/resources:ash_test_resources_with_content_100_percent",
]
}
static_library("test_support") {
......
......@@ -328,7 +328,7 @@ bool DisplayColorManager::LoadCalibrationForDisplay(
// TODO(mcasas): correct UMA s/Id/Code/, https://crbug.com/821393.
UMA_HISTOGRAM_BOOLEAN("Ash.DisplayColorManager.ValidProductId",
valid_product_code);
if (!valid_product_code)
if (!valid_product_code || !quirks::QuirksManager::HasInstance())
return false;
quirks::QuirksManager::Get()->RequestIccProfilePath(
......
......@@ -144,7 +144,7 @@ void ShellBrowserMainParts::PreMainMessageLoopRun() {
base::Unretained(browser_context_.get()), nullptr),
base::BindRepeating(base::IgnoreResult(&EmbeddedBrowser::Create),
base::Unretained(browser_context_.get()),
GURL("https://www.google.com")));
GURL("https://www.google.com"), base::nullopt));
}
}
......
......@@ -45,10 +45,11 @@ class BrowserWidgetDelegateView : public views::WidgetDelegateView {
} // namespace
EmbeddedBrowser::EmbeddedBrowser(content::BrowserContext* context,
const GURL& url)
const GURL& url,
const gfx::Rect& bounds)
: widget_(new views::Widget) {
views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
params.bounds = gfx::Rect(20, 20, 800, 600);
params.bounds = bounds;
params.delegate = new BrowserWidgetDelegateView(context, url);
widget_->Init(params);
WindowState::Get(widget_->GetNativeWindow())->SetWindowPositionManaged(true);
......@@ -63,10 +64,14 @@ aura::Window* EmbeddedBrowser::GetWindow() {
// static
aura::Window* EmbeddedBrowser::Create(content::BrowserContext* context,
const GURL& url) {
const GURL& url,
base::Optional<gfx::Rect> bounds) {
static const gfx::Rect default_bounds(20, 20, 800, 600);
// EmbeddedBrowser deletes itself when the widget is closed.
aura::Window* browser_window =
(new EmbeddedBrowser(context, url))->GetWindow();
(new EmbeddedBrowser(context, url, bounds ? *bounds : default_bounds))
->GetWindow();
browser_window->SetProperty(aura::client::kAppType,
static_cast<int>(ash::AppType::BROWSER));
return browser_window;
......
......@@ -8,6 +8,8 @@
#include <memory>
#include "base/macros.h"
#include "base/optional.h"
#include "ui/gfx/geometry/rect.h"
class GURL;
......@@ -29,16 +31,19 @@ namespace shell {
// Exercises ServerRemoteViewHost to embed a content::WebContents.
class EmbeddedBrowser {
public:
EmbeddedBrowser(content::BrowserContext* context, const GURL& url);
~EmbeddedBrowser();
aura::Window* GetWindow();
// Factory.
static aura::Window* Create(content::BrowserContext* context,
const GURL& url);
const GURL& url,
base::Optional<gfx::Rect> bounds = base::nullopt);
private:
EmbeddedBrowser(content::BrowserContext* context,
const GURL& url,
const gfx::Rect& bounds);
~EmbeddedBrowser();
// Callback invoked when the embedding is broken.
void OnUnembed();
......
......@@ -6,6 +6,7 @@
#include <utility>
#include "ash/shelf/shelf_constants.h"
#include "ash/shell.h"
#include "ash/shell/content/client/shell_browser_main_parts.h"
#include "ash/shell/content/embedded_browser.h"
......@@ -121,7 +122,6 @@ AshContentTest::AshContentTest()
AshContentTest::~AshContentTest() = default;
void AshContentTest::SetUp() {
content::ContentBrowserTest::SetUp();
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
// Add command line arguments that are used by all AshContentTests.
if (!command_line->HasSwitch(switches::kHostWindowBounds) &&
......@@ -132,6 +132,7 @@ void AshContentTest::SetUp() {
command_line->AppendSwitchASCII(switches::kHostWindowBounds,
"0+0-1280x800");
}
content::ContentBrowserTest::SetUp();
}
void AshContentTest::SetUpOnMainThread() {
......@@ -145,6 +146,10 @@ void AshContentTest::SetUpOnMainThread() {
"benchmark,cc,viz,input,latency,gpu,rail,toplevel,ui,views,viz"),
GetUMAHistogramNames());
}
gfx::Size display_size = ash::Shell::GetPrimaryRootWindow()->bounds().size();
test_window_size_.set_height((display_size.height() - ash::kShelfSize) *
0.95f);
test_window_size_.set_width(display_size.width() * 0.7f);
}
void AshContentTest::TearDownOnMainThread() {
......@@ -164,14 +169,15 @@ void AshContentTest::TearDownOnMainThread() {
aura::Window* AshContentTest::CreateBrowserWindow(const GURL& url) {
return ash::shell::EmbeddedBrowser::Create(
ash::shell::ShellBrowserMainParts::GetBrowserContext(), url);
ash::shell::ShellBrowserMainParts::GetBrowserContext(), url,
gfx::Rect(test_window_size_));
}
aura::Window* AshContentTest::CreateTestWindow() {
views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds(
new ash::shell::WindowTypeLauncher(base::NullCallback(),
base::NullCallback()),
ash::Shell::GetPrimaryRootWindow(), gfx::Rect(600, 800));
ash::Shell::GetPrimaryRootWindow(), gfx::Rect(test_window_size_));
widget->GetNativeView()->SetName("WindowTypeLauncher");
widget->Show();
......
......@@ -33,6 +33,7 @@ class AshContentTest : public content::ContentBrowserTest {
private:
class Tracer;
gfx::Size test_window_size_;
bool enable_trace_;
std::unique_ptr<Tracer> tracer_;
......
......@@ -36,6 +36,7 @@
#include "base/bind.h"
#include "base/run_loop.h"
#include "base/strings/string_split.h"
#include "base/system/sys_info.h"
#include "base/token.h"
#include "chromeos/audio/cras_audio_handler.h"
#include "chromeos/dbus/audio/cras_audio_client.h"
......@@ -84,7 +85,8 @@ void AshTestHelper::SetUp(const InitParams& init_params,
// TODO(jamescook): Can we do this without changing command line?
// Use the origin (1,1) so that it doesn't over
// lap with the native mouse cursor.
if (!command_line_->GetProcessCommandLine()->HasSwitch(
if (!base::SysInfo::IsRunningOnChromeOS() &&
!command_line_->GetProcessCommandLine()->HasSwitch(
::switches::kHostWindowBounds)) {
// TODO(oshima): Disable native events instead of adding offset.
command_line_->GetProcessCommandLine()->AppendSwitchASCII(
......
......@@ -92,6 +92,11 @@ QuirksManager* QuirksManager::Get() {
return manager_;
}
// static
bool QuirksManager::HasInstance() {
return !!manager_;
}
// static
void QuirksManager::RegisterPrefs(PrefRegistrySimple* registry) {
registry->RegisterDictionaryPref(prefs::kQuirksClientLastServerCheck);
......
......@@ -72,6 +72,7 @@ class QUIRKS_EXPORT QuirksManager {
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory);
static void Shutdown();
static QuirksManager* Get();
static bool HasInstance();
static void RegisterPrefs(PrefRegistrySimple* registry);
......
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