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