Commit c4fe601d authored by Tom Anderson's avatar Tom Anderson Committed by Commit Bot

Cleanup GTK build code

This removes the dependency of //c/b/u/gtk on //c/b/u.  This will
allow us to move //c/b/u/gtk out of //c/b to a better home like
//ui/gtk once the //content dependency is removed in a separate CL.

This also removes some select file dialog tests which had all of
their tests disabled and never added any value.

R=sky
BUG=None

Change-Id: I38403a967593c76ea55c14315a63a8190e5cae33
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2093015Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Thomas Anderson <thomasanderson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#748888}
parent b4d64171
...@@ -20,14 +20,13 @@ pkg_config("gtk_internal_config") { ...@@ -20,14 +20,13 @@ pkg_config("gtk_internal_config") {
] ]
} }
# Basically no parts of Chrome should depend on GTK. To prevent accidents, the
# parts that explicitly need GTK are whitelisted on this target.
group("gtk") { group("gtk") {
visibility = [ visibility = [
"//chrome/test:interactive_ui_tests", # This is the only target in Chrome that should depend on GTK.
"//chrome/test:unit_tests", "//chrome/browser/ui/gtk:*",
# These are all for WebRTC.
"//examples:peerconnection_client", "//examples:peerconnection_client",
"//gpu/gles2_conform_support:gles2_conform_test_windowless",
"//remoting/host/linux", "//remoting/host/linux",
"//remoting/host/it2me:common", "//remoting/host/it2me:common",
"//remoting/host/it2me:remote_assistance_host", "//remoting/host/it2me:remote_assistance_host",
...@@ -36,7 +35,6 @@ group("gtk") { ...@@ -36,7 +35,6 @@ group("gtk") {
"//remoting/host:remoting_me2me_host_static", "//remoting/host:remoting_me2me_host_static",
"//remoting/test:it2me_standalone_host_main", "//remoting/test:it2me_standalone_host_main",
"//webrtc/examples:peerconnection_client", "//webrtc/examples:peerconnection_client",
"//chrome/browser/ui/gtk:*",
] ]
public_configs = [ ":gtk_internal_config" ] public_configs = [ ":gtk_internal_config" ]
......
...@@ -58,7 +58,6 @@ jumbo_component("gtk") { ...@@ -58,7 +58,6 @@ jumbo_component("gtk") {
"//base", "//base",
"//build/config/linux/gtk", "//build/config/linux/gtk",
"//build/config/linux/gtk:gtkprint", "//build/config/linux/gtk:gtkprint",
"//chrome/browser/ui/views",
"//chrome/common:constants", "//chrome/common:constants",
"//components/prefs", "//components/prefs",
"//content/public/browser", "//content/public/browser",
......
include_rules = [
"+chrome/browser/ui/views",
]
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/gtk/select_file_dialog_impl_gtk.h"
#include "base/run_loop.h"
#include "base/task/thread_pool/thread_pool_instance.h"
#include "chrome/browser/ui/chrome_select_file_policy.h"
#include "chrome/browser/ui/gtk/gtk_ui.h"
#include "chrome/test/base/scoped_testing_local_state.h"
#include "chrome/test/base/testing_browser_process.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/test/browser_task_environment.h"
#include "testing/gtest/include/gtest/gtest.h"
using base::RunLoop;
using content::BrowserThread;
class SelectFileDialogImplGtkTest : public testing::Test {
public:
SelectFileDialogImplGtkTest() = default;
void SetUp() override {
gtk_ui_.reset(BuildGtkUi());
ui::ShellDialogLinux::SetInstance(gtk_ui_.get());
}
void TearDown() override {
ui::ShellDialogLinux::SetInstance(nullptr);
gtk_ui_.reset();
}
private:
std::unique_ptr<views::LinuxUI> gtk_ui_;
};
namespace gtk {
class FilePicker : public ui::SelectFileDialog::Listener {
public:
explicit FilePicker(ui::SelectFileDialog::Type type) {
select_file_dialog_ = ui::SelectFileDialog::Create(
this, std::make_unique<ChromeSelectFilePolicy>(nullptr));
ui::SelectFileDialog::FileTypeInfo file_types;
file_types.allowed_paths = ui::SelectFileDialog::FileTypeInfo::ANY_PATH;
const base::FilePath file_path;
select_file_dialog_->SelectFile(
type, base::string16(), file_path, &file_types, 0,
base::FilePath::StringType(), nullptr, nullptr);
}
~FilePicker() override {
SelectFileDialogImplGTK* file_dialog =
static_cast<SelectFileDialogImplGTK*>(select_file_dialog_.get());
while (!file_dialog->dialogs_.empty())
gtk_widget_destroy(*(file_dialog->dialogs_.begin()));
select_file_dialog_->ListenerDestroyed();
}
bool canCreateFolder() {
return gtk_file_chooser_get_create_folders(getChooser());
}
bool canSelectMultiple() {
return gtk_file_chooser_get_select_multiple(getChooser());
}
const gchar* getTitle() {
return gtk_window_get_title(
GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(getChooser()))));
}
// SelectFileDialog::Listener implementation.
void FileSelected(const base::FilePath& path,
int index,
void* params) override {}
private:
// Dialog box used for opening and saving files.
scoped_refptr<ui::SelectFileDialog> select_file_dialog_;
GtkFileChooser* getChooser() {
auto* dialog =
static_cast<SelectFileDialogImplGTK*>(select_file_dialog_.get());
return GTK_FILE_CHOOSER(*(dialog->dialogs_.begin()));
}
DISALLOW_COPY_AND_ASSIGN(FilePicker);
};
// Note: The tests below were disabled for defined(ADDRESS_SANITIZER) with the
// following reasoning:
// Glib runs glib_init() when it is loaded by dl, and in the process
// allocates some memory that is intentionally never freed.
// Targeted suppression of the memory leak was not possible.
// Flaky, see crbug.com/853079.
TEST_F(SelectFileDialogImplGtkTest, DISABLED_SelectExistingFolder) {
content::BrowserTaskEnvironment task_environment_;
ScopedTestingLocalState local_state(TestingBrowserProcess::GetGlobal());
FilePicker file_picker(ui::SelectFileDialog::SELECT_EXISTING_FOLDER);
EXPECT_FALSE(file_picker.canSelectMultiple());
EXPECT_FALSE(file_picker.canCreateFolder());
EXPECT_STREQ("Select Folder", file_picker.getTitle());
base::ThreadPoolInstance::Get()->FlushForTesting();
RunLoop().RunUntilIdle();
}
// Flaky, see crbug.com/853079.
TEST_F(SelectFileDialogImplGtkTest, DISABLED_SelectUploadFolder) {
content::BrowserTaskEnvironment task_environment_;
ScopedTestingLocalState local_state(TestingBrowserProcess::GetGlobal());
FilePicker file_picker(ui::SelectFileDialog::SELECT_UPLOAD_FOLDER);
EXPECT_FALSE(file_picker.canSelectMultiple());
EXPECT_FALSE(file_picker.canCreateFolder());
EXPECT_STREQ("Select Folder to Upload", file_picker.getTitle());
base::ThreadPoolInstance::Get()->FlushForTesting();
RunLoop().RunUntilIdle();
}
// Flaky, see crbug.com/853079.
TEST_F(SelectFileDialogImplGtkTest, DISABLED_SelectFolder) {
content::BrowserTaskEnvironment task_environment_;
ScopedTestingLocalState local_state(TestingBrowserProcess::GetGlobal());
FilePicker file_picker(ui::SelectFileDialog::SELECT_FOLDER);
EXPECT_FALSE(file_picker.canSelectMultiple());
EXPECT_TRUE(file_picker.canCreateFolder());
EXPECT_STREQ("Select Folder", file_picker.getTitle());
base::ThreadPoolInstance::Get()->FlushForTesting();
RunLoop().RunUntilIdle();
}
} // namespace gtk
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/macros.h"
#include "build/build_config.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/chrome_select_file_policy.h"
#include "chrome/browser/ui/gtk/select_file_dialog_impl_gtk.h"
#include "chrome/browser/ui/view_ids.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/interactive_test_utils.h"
#include "chrome/test/base/ui_test_utils.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "ui/shell_dialogs/select_file_dialog.h"
#include "ui/views/test/widget_test.h"
#include "ui/views/widget/widget.h"
using BrowserSelectFileDialogTest = InProcessBrowserTest;
namespace gtk {
// FilePicker opens a GtkFileChooser.
class FilePicker : public ui::SelectFileDialog::Listener {
public:
explicit FilePicker(BrowserWindow* window) {
select_file_dialog_ = ui::SelectFileDialog::Create(
this, std::make_unique<ChromeSelectFilePolicy>(nullptr));
gfx::NativeWindow parent_window = window->GetNativeWindow();
ui::SelectFileDialog::FileTypeInfo file_types;
file_types.allowed_paths = ui::SelectFileDialog::FileTypeInfo::ANY_PATH;
const base::FilePath file_path;
select_file_dialog_->SelectFile(
ui::SelectFileDialog::SELECT_OPEN_FILE, base::string16(), file_path,
&file_types, 0, base::FilePath::StringType(), parent_window, nullptr);
}
~FilePicker() override { select_file_dialog_->ListenerDestroyed(); }
void Close() {
SelectFileDialogImplGTK* file_dialog =
static_cast<SelectFileDialogImplGTK*>(select_file_dialog_.get());
while (!file_dialog->dialogs_.empty())
gtk_widget_destroy(*(file_dialog->dialogs_.begin()));
}
// SelectFileDialog::Listener implementation.
void FileSelected(const base::FilePath& path,
int index,
void* params) override {}
private:
// Dialog box used for opening and saving files.
scoped_refptr<ui::SelectFileDialog> select_file_dialog_;
DISALLOW_COPY_AND_ASSIGN(FilePicker);
};
} // namespace gtk
// Leaks in GtkFileChooserDialog. http://crbug.com/537468
// Flaky on Linux. http://crbug.com/700134
#if defined(ADDRESS_SANITIZER) || defined(OS_LINUX)
#define MAYBE_ModalTest DISABLED_ModalTest
#else
#define MAYBE_ModalTest ModalTest
#endif
// Test that the file-picker is modal.
IN_PROC_BROWSER_TEST_F(BrowserSelectFileDialogTest, MAYBE_ModalTest) {
// Bring the native window to the foreground. Returns true on success.
ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
ASSERT_TRUE(browser()->window()->IsActive());
gtk::FilePicker file_picker(browser()->window());
gfx::NativeWindow window = browser()->window()->GetNativeWindow();
views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window);
ASSERT_NE(nullptr, widget);
// Run a nested loop until the browser window becomes inactive
// so that the file-picker can be active.
views::test::WidgetActivationWaiter waiter_inactive(widget, false);
waiter_inactive.Wait();
EXPECT_FALSE(browser()->window()->IsActive());
ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER);
// The window should not get focus due to modal dialog.
EXPECT_FALSE(browser()->window()->IsActive());
ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
EXPECT_FALSE(browser()->window()->IsActive());
ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow(window));
EXPECT_FALSE(browser()->window()->IsActive());
ASSERT_TRUE(ui_test_utils::SendKeyPressSync(browser(), ui::VKEY_TAB, false,
false, true, false));
EXPECT_FALSE(browser()->window()->IsActive());
file_picker.Close();
// Run a nested loop until the browser window becomes active.
views::test::WidgetActivationWaiter wait_active(widget, true);
wait_active.Wait();
ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER);
EXPECT_TRUE(browser()->window()->IsActive());
}
...@@ -8,7 +8,6 @@ import("//build/config/chrome_build.gni") ...@@ -8,7 +8,6 @@ import("//build/config/chrome_build.gni")
import("//build/config/compiler/compiler.gni") import("//build/config/compiler/compiler.gni")
import("//build/config/crypto.gni") import("//build/config/crypto.gni")
import("//build/config/features.gni") import("//build/config/features.gni")
import("//build/config/linux/gtk/gtk.gni")
import("//build/config/ui.gni") import("//build/config/ui.gni")
import("//build/toolchain/toolchain.gni") import("//build/toolchain/toolchain.gni")
import("//build/util/version.gni") import("//build/util/version.gni")
...@@ -4895,10 +4894,6 @@ test("unit_tests") { ...@@ -4895,10 +4894,6 @@ test("unit_tests") {
"../browser/upgrade_detector/get_installed_version_linux_unittest.cc", "../browser/upgrade_detector/get_installed_version_linux_unittest.cc",
] ]
} }
if (use_gtk) {
sources += [ "../browser/ui/gtk/select_file_dialog_impl_gtk_unittest.cc" ]
deps += [ "//build/config/linux/gtk" ]
}
if (is_android || is_chromeos) { if (is_android || is_chromeos) {
sources += [ "../browser/media/protected_media_identifier_permission_context_unittest.cc" ] sources += [ "../browser/media/protected_media_identifier_permission_context_unittest.cc" ]
...@@ -4916,9 +4911,6 @@ test("unit_tests") { ...@@ -4916,9 +4911,6 @@ test("unit_tests") {
if (use_gio) { if (use_gio) {
configs += [ "//build/linux:gio_config" ] configs += [ "//build/linux:gio_config" ]
} }
if (!is_chromeos && !use_ozone && is_linux) {
deps += [ "//chrome/browser/ui/gtk" ]
}
if (enable_service_discovery) { if (enable_service_discovery) {
sources += [ sources += [
...@@ -5906,11 +5898,6 @@ if (!is_android) { ...@@ -5906,11 +5898,6 @@ if (!is_android) {
# suites, it seems like one or another starts timing out too. # suites, it seems like one or another starts timing out too.
"../browser/ui/views/keyboard_access_browsertest.cc", "../browser/ui/views/keyboard_access_browsertest.cc",
] ]
if (!use_ozone) {
sources +=
[ "../browser/ui/gtk/select_file_dialog_interactive_uitest.cc" ]
deps += [ "//build/config/linux/gtk" ]
}
} }
if (!is_chromeos) { if (!is_chromeos) {
sources += [ "../browser/ui/views/global_media_controls/media_dialog_view_interactive_browsertest.cc" ] sources += [ "../browser/ui/views/global_media_controls/media_dialog_view_interactive_browsertest.cc" ]
......
...@@ -135,6 +135,12 @@ jumbo_component("accessibility") { ...@@ -135,6 +135,12 @@ jumbo_component("accessibility") {
"platform/ax_platform_text_boundary.h", "platform/ax_platform_text_boundary.h",
] ]
if (use_atk) {
# ax_platform_text_boundary.h includes atk.h, so ATK is needed as a public
# config to ensure anything that includes this is able to find atk.h.
public_configs = [ "//build/config/linux/atk" ]
}
if (is_mac) { if (is_mac) {
sources += [ sources += [
"platform/ax_platform_node_mac.h", "platform/ax_platform_node_mac.h",
......
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