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

Unified Diff: chrome/browser/ui/window_sizer/window_sizer_ash_unittest.cc

Issue 11072002: Combined window positioning and show state determiniation in the WindowSizer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed more build issues Created 8 years, 2 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/window_sizer/window_sizer_ash_unittest.cc
diff --git a/chrome/browser/ui/window_sizer/window_sizer_ash_unittest.cc b/chrome/browser/ui/window_sizer/window_sizer_ash_unittest.cc
index 4cb09de078633a5d81b45e6d22d2022ad02ecd9c..ee07942c737b4e24c52e34ff07854b7f166ab419 100644
--- a/chrome/browser/ui/window_sizer/window_sizer_ash_unittest.cc
+++ b/chrome/browser/ui/window_sizer/window_sizer_ash_unittest.cc
@@ -2,86 +2,22 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/ui/window_sizer/window_sizer.h"
-
-#include <vector>
+#include "chrome/browser/ui/window_sizer/window_sizer_common_unittest.h"
#include "ash/shell.h"
-#include "ash/test/ash_test_base.h"
#include "ash/test/test_shell_delegate.h"
#include "ash/wm/window_resizer.h"
#include "base/compiler_specific.h"
-#include "base/logging.h"
#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/window_sizer/window_sizer_common_unittest.h"
+#include "chrome/common/chrome_switches.h"
#include "chrome/test/base/testing_profile.h"
-#include "chrome/test/base/test_browser_window.h"
-#include "content/public/browser/browser_thread.h"
#include "content/public/test/render_view_test.h"
-#include "content/public/test/test_browser_thread.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h"
#include "ui/aura/env.h"
#include "ui/aura/root_window.h"
#include "ui/aura/test/test_windows.h"
-
-namespace {
-
-typedef ash::test::AshTestBase WindowSizerTest;
-
-// A special test class for use with browser creation - it will create a
-// browser thread and deletes it after all other things have been destroyed.
-class WindowSizerTestWithBrowser : public WindowSizerTest {
- public:
- WindowSizerTestWithBrowser();
- virtual ~WindowSizerTestWithBrowser();
-
- private:
- // Note: It is important to delete the thread after the browser instances got
- // deleted. For this we transfer the thread here.
- scoped_ptr<content::TestBrowserThread> ui_thread_;
-
- DISALLOW_COPY_AND_ASSIGN(WindowSizerTestWithBrowser);
-};
-
-WindowSizerTestWithBrowser::WindowSizerTestWithBrowser() {
- // Set up a UI message thread.
- MessageLoopForUI* ui_loop = message_loop();
- ui_thread_.reset(
- new content::TestBrowserThread(content::BrowserThread::UI, ui_loop));
-}
-
-WindowSizerTestWithBrowser::~WindowSizerTestWithBrowser() {
-}
-
-// 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);
- virtual ~TestBrowserWindowAura();
-
- virtual gfx::NativeWindow GetNativeWindow() OVERRIDE {
- return native_window_;
- }
-
- virtual gfx::Rect GetBounds() const {
- return native_window_->bounds();
- }
-
- private:
- gfx::NativeWindow native_window_;
-
- DISALLOW_COPY_AND_ASSIGN(TestBrowserWindowAura);
-};
-
-} // namespace
-
-TestBrowserWindowAura::TestBrowserWindowAura(aura::Window *native_window)
- : native_window_(native_window) {
-}
-
-TestBrowserWindowAura::~TestBrowserWindowAura() {}
+#include "ui/aura/client/aura_constants.h"
int AlignToGridRoundDown(int location, int grid_size) {
if (grid_size <= 1 || location % grid_size == 0)
@@ -763,3 +699,81 @@ TEST_F(WindowSizerTest, AdjustFitSize) {
EXPECT_EQ("924,668 100x100", window_bounds.ToString());
}
}
+
+// Test that the show state is properly returned for non default cases.
+TEST_F(WindowSizerTestWithBrowser, TestShowState) {
+ // Creating a browser & window to play with.
+ scoped_ptr<aura::Window> window(
+ aura::test::CreateTestWindowWithId(0, NULL));
+ window->SetBounds(gfx::Rect(16, 32, 640, 320));
+
+ scoped_ptr<TestingProfile> profile(new TestingProfile());
+
+ scoped_ptr<BrowserWindow> browser_window(
+ new TestBrowserWindowAura(window.get()));
+ Browser::CreateParams window_params(Browser::TYPE_TABBED, profile.get());
+ window_params.window = browser_window.get();
+ scoped_ptr<Browser> browser(new Browser(window_params));
+
+ // Create also a popup browser since that behaves different.
+ scoped_ptr<aura::Window> popup(
+ aura::test::CreateTestWindowWithId(1, NULL));
+ popup->SetBounds(gfx::Rect(16, 32, 128, 256));
+
+ scoped_ptr<BrowserWindow> browser_popup(
+ new TestBrowserWindowAura(popup.get()));
+ Browser::CreateParams popup_params(Browser::TYPE_POPUP, profile.get());
+ popup_params.window = browser_window.get();
+ scoped_ptr<Browser> popup_browser(new Browser(popup_params));
+
+ // Tabbed windows should retrieve the saved window state - since there is a
+ // top window.
+ EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED,
+ GetWindowShowState(ui::SHOW_STATE_MAXIMIZED,
+ ui::SHOW_STATE_NORMAL,
+ BOTH,
+ browser.get()));
+ EXPECT_EQ(ui::SHOW_STATE_DEFAULT,
+ GetWindowShowState(ui::SHOW_STATE_DEFAULT,
+ ui::SHOW_STATE_NORMAL,
+ BOTH,
+ browser.get()));
+ // Non tabbed windows should always follow the window saved visibility state.
+ EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED,
+ GetWindowShowState(ui::SHOW_STATE_MAXIMIZED,
+ ui::SHOW_STATE_NORMAL,
+ BOTH,
+ popup_browser.get()));
+ // The non tabbed window will take the status of the last active of its kind.
+ EXPECT_EQ(ui::SHOW_STATE_NORMAL,
+ GetWindowShowState(ui::SHOW_STATE_DEFAULT,
+ ui::SHOW_STATE_NORMAL,
+ BOTH,
+ popup_browser.get()));
+
+ // Now create a top level window and check again for both. Only the tabbed
+ // window should follow the top level window's state.
+ // Creating a browser & window to play with.
+ scoped_ptr<aura::Window> window2(
+ aura::test::CreateTestWindowWithId(0, NULL));
+ window->SetBounds(gfx::Rect(16, 32, 640, 320));
+
+ scoped_ptr<BrowserWindow> browser_window2(
+ new TestBrowserWindowAura(window2.get()));
+ Browser::CreateParams window2_params(Browser::TYPE_TABBED, profile.get());
+ window2_params.window = browser_window2.get();
+ scoped_ptr<Browser> browser2(new Browser(window2_params));
+
+ // A tabbed window should now take the top level window state.
+ EXPECT_EQ(ui::SHOW_STATE_DEFAULT,
+ GetWindowShowState(ui::SHOW_STATE_MAXIMIZED,
+ ui::SHOW_STATE_DEFAULT,
+ BOTH,
+ browser2.get()));
+ // Non tabbed windows should always follow the window saved visibility state.
+ EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED,
+ GetWindowShowState(ui::SHOW_STATE_MAXIMIZED,
+ ui::SHOW_STATE_MINIMIZED,
+ BOTH,
+ popup_browser.get()));
+}

Powered by Google App Engine
This is Rietveld 408576698