Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2633)

Unified Diff: chrome/browser/ui/ash/window_positioner_unittest.cc

Issue 1198313003: Fix the browser match rules. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/ash/window_positioner_unittest.cc
diff --git a/chrome/browser/ui/ash/window_positioner_unittest.cc b/chrome/browser/ui/ash/window_positioner_unittest.cc
index 76d9227917e15058816b346c01841b1140090544..d315789aa258f2ecb928e23746544d7d026d8d30 100644
--- a/chrome/browser/ui/ash/window_positioner_unittest.cc
+++ b/chrome/browser/ui/ash/window_positioner_unittest.cc
@@ -24,31 +24,6 @@
namespace ash {
namespace test {
-namespace {
-
-// A browser window proxy which is able to associate an aura native window with
-// it.
-class TestBrowserWindowAura : public TestBrowserWindow {
- public:
- explicit TestBrowserWindowAura(aura::Window* native_window);
- ~TestBrowserWindowAura() override;
-
- gfx::NativeWindow GetNativeWindow() const override { return native_window_; }
-
- private:
- gfx::NativeWindow native_window_;
-
- DISALLOW_COPY_AND_ASSIGN(TestBrowserWindowAura);
-};
-
-TestBrowserWindowAura::TestBrowserWindowAura(aura::Window *native_window)
- : native_window_(native_window) {
-}
-
-TestBrowserWindowAura::~TestBrowserWindowAura() {}
-
-} // namespace
-
// A test class for preparing window positioner tests - it creates a testing
// base by adding a window and a popup which can be independently
// positioned to see where the positioner will place the window.
@@ -60,11 +35,8 @@ class WindowPositionerTest : public AshTestBase {
void TearDown() override;
protected:
- aura::Window* window() { return window_.get(); }
- aura::Window* popup() { return popup_.get(); }
-
- Browser* window_browser() { return window_owning_browser_.get(); }
- Browser* popup_browser() { return popup_owning_browser_.get(); }
+ aura::Window* window() { return browser_window_->GetNativeWindow(); }
+ aura::Window* popup() { return browser_popup_->GetNativeWindow(); }
WindowPositioner* window_positioner() { return window_positioner_; }
@@ -77,68 +49,52 @@ class WindowPositionerTest : public AshTestBase {
// These two need to be deleted after everything else is gone.
TestingProfile profile_;
- // These get created for each session.
- scoped_ptr<aura::Window> window_;
- scoped_ptr<aura::Window> popup_;
-
scoped_ptr<BrowserWindow> browser_window_;
scoped_ptr<BrowserWindow> browser_popup_;
- scoped_ptr<Browser> window_owning_browser_;
- scoped_ptr<Browser> popup_owning_browser_;
-
DISALLOW_COPY_AND_ASSIGN(WindowPositionerTest);
};
WindowPositionerTest::WindowPositionerTest()
: grid_size_(WindowPositioner::kMinimumWindowOffset),
- window_positioner_(NULL) {
+ window_positioner_(nullptr) {
}
void WindowPositionerTest::SetUp() {
AshTestBase::SetUp();
// Create some default dummy windows.
- window_.reset(CreateTestWindowInShellWithId(0));
- window_->SetBounds(gfx::Rect(16, 32, 640, 320));
- popup_.reset(CreateTestWindowInShellWithId(1));
- popup_->SetBounds(gfx::Rect(16, 32, 128, 256));
+ aura::Window* window = CreateTestWindowInShellWithId(0);
msw 2015/07/07 18:11:54 These should still be scoped_ptrs.
xdai1 2015/07/08 00:26:21 It seems |window| is owned by TestBrowserWindowAur
msw 2015/07/08 01:13:59 Hmm, that does seem to be the case. The transfer o
xdai1 2015/07/08 21:34:21 Yes, I agree it would be more clearer: modifying t
+ window->SetBounds(gfx::Rect(16, 32, 640, 320));
+ aura::Window* popup = CreateTestWindowInShellWithId(1);
+ popup->SetBounds(gfx::Rect(16, 32, 128, 256));
// Create a browser for the window.
- browser_window_.reset(new TestBrowserWindowAura(window_.get()));
+ browser_window_.reset(new TestBrowserWindowAura(window));
Browser::CreateParams window_params(&profile_,
chrome::HOST_DESKTOP_TYPE_ASH);
window_params.window = browser_window_.get();
- window_owning_browser_.reset(new Browser(window_params));
// Creating a browser for the popup.
- browser_popup_.reset(new TestBrowserWindowAura(popup_.get()));
+ browser_popup_.reset(new TestBrowserWindowAura(popup));
Browser::CreateParams popup_params(Browser::TYPE_POPUP, &profile_,
chrome::HOST_DESKTOP_TYPE_ASH);
popup_params.window = browser_popup_.get();
- popup_owning_browser_.reset(new Browser(popup_params));
// We hide all windows upon start - each user is required to set it up
// as he needs it.
- window()->Hide();
- popup()->Hide();
+ window->Hide();
+ popup->Hide();
window_positioner_ = new WindowPositioner();
}
void WindowPositionerTest::TearDown() {
// Since the AuraTestBase is needed to create our assets, we have to
// also delete them before we tear it down.
- window_owning_browser_.reset(NULL);
- popup_owning_browser_.reset(NULL);
-
- browser_window_.reset(NULL);
- browser_popup_.reset(NULL);
-
- window_.reset(NULL);
- popup_.reset(NULL);
-
+ browser_window_.reset(nullptr);
+ browser_popup_.reset(nullptr);
AshTestBase::TearDown();
delete window_positioner_;
- window_positioner_ = NULL;
+ window_positioner_ = nullptr;
}
int AlignToGridRoundDown(int location, int grid_size) {

Powered by Google App Engine
This is Rietveld 408576698