| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/gfx/rect.h" |
| 9 #include "base/test_file_util.h" | 10 #include "base/test_file_util.h" |
| 10 #include "base/values.h" | 11 #include "base/values.h" |
| 11 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 12 #include "chrome/common/chrome_constants.h" | 13 #include "chrome/common/chrome_constants.h" |
| 13 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
| 14 #include "chrome/common/json_value_serializer.h" | 15 #include "chrome/common/json_value_serializer.h" |
| 15 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
| 16 #include "chrome/test/automation/browser_proxy.h" | 17 #include "chrome/test/automation/browser_proxy.h" |
| 17 #include "chrome/test/automation/window_proxy.h" | 18 #include "chrome/test/automation/window_proxy.h" |
| 18 #include "chrome/test/ui/ui_test.h" | 19 #include "chrome/test/ui/ui_test.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 ASSERT_TRUE(root.get()); | 90 ASSERT_TRUE(root.get()); |
| 90 ASSERT_TRUE(root->IsType(Value::TYPE_DICTIONARY)); | 91 ASSERT_TRUE(root->IsType(Value::TYPE_DICTIONARY)); |
| 91 | 92 |
| 92 DictionaryValue* root_dict = static_cast<DictionaryValue*>(root.get()); | 93 DictionaryValue* root_dict = static_cast<DictionaryValue*>(root.get()); |
| 93 | 94 |
| 94 // Retrieve the screen rect for the launched window | 95 // Retrieve the screen rect for the launched window |
| 95 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); | 96 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); |
| 96 ASSERT_TRUE(browser.get()); | 97 ASSERT_TRUE(browser.get()); |
| 97 scoped_refptr<WindowProxy> window(browser->GetWindow()); | 98 scoped_refptr<WindowProxy> window(browser->GetWindow()); |
| 98 | 99 |
| 99 HWND hWnd; | 100 gfx::Rect bounds; |
| 100 ASSERT_TRUE(window->GetHWND(&hWnd)); | 101 ASSERT_TRUE(window->GetBounds(&bounds)); |
| 101 | |
| 102 WINDOWPLACEMENT window_placement; | |
| 103 ASSERT_TRUE(GetWindowPlacement(hWnd, &window_placement)); | |
| 104 | 102 |
| 105 // Retrieve the expected rect values from "Preferences" | 103 // Retrieve the expected rect values from "Preferences" |
| 106 int bottom = 0; | 104 int bottom = 0; |
| 107 std::wstring kBrowserWindowPlacement(prefs::kBrowserWindowPlacement); | 105 std::wstring kBrowserWindowPlacement(prefs::kBrowserWindowPlacement); |
| 108 EXPECT_TRUE(root_dict->GetInteger(kBrowserWindowPlacement + L".bottom", | 106 EXPECT_TRUE(root_dict->GetInteger(kBrowserWindowPlacement + L".bottom", |
| 109 &bottom)); | 107 &bottom)); |
| 110 EXPECT_EQ(bottom, window_placement.rcNormalPosition.bottom); | 108 EXPECT_EQ(bottom, bounds.y() + bounds.height()); |
| 111 | 109 |
| 112 int top = 0; | 110 int top = 0; |
| 113 EXPECT_TRUE(root_dict->GetInteger(kBrowserWindowPlacement + L".top", | 111 EXPECT_TRUE(root_dict->GetInteger(kBrowserWindowPlacement + L".top", |
| 114 &top)); | 112 &top)); |
| 115 EXPECT_EQ(top, window_placement.rcNormalPosition.top); | 113 EXPECT_EQ(top, bounds.y()); |
| 116 | 114 |
| 117 int left = 0; | 115 int left = 0; |
| 118 EXPECT_TRUE(root_dict->GetInteger(kBrowserWindowPlacement + L".left", | 116 EXPECT_TRUE(root_dict->GetInteger(kBrowserWindowPlacement + L".left", |
| 119 &left)); | 117 &left)); |
| 120 EXPECT_EQ(left, window_placement.rcNormalPosition.left); | 118 EXPECT_EQ(left, bounds.x()); |
| 121 | 119 |
| 122 int right = 0; | 120 int right = 0; |
| 123 EXPECT_TRUE(root_dict->GetInteger(kBrowserWindowPlacement + L".right", | 121 EXPECT_TRUE(root_dict->GetInteger(kBrowserWindowPlacement + L".right", |
| 124 &right)); | 122 &right)); |
| 125 EXPECT_EQ(right, window_placement.rcNormalPosition.right); | 123 EXPECT_EQ(right, bounds.x() + bounds.width()); |
| 126 | 124 |
| 127 // Find if launched window is maximized | 125 // Find if launched window is maximized. |
| 128 bool is_window_maximized = (window_placement.showCmd == SW_MAXIMIZE); | 126 bool is_window_maximized = false; |
| 129 | 127 ASSERT_TRUE(window->IsMaximized(&is_window_maximized)); |
| 130 bool is_maximized = false; | 128 bool is_maximized = false; |
| 131 EXPECT_TRUE(root_dict->GetBoolean(kBrowserWindowPlacement + L".maximized", | 129 EXPECT_TRUE(root_dict->GetBoolean(kBrowserWindowPlacement + L".maximized", |
| 132 &is_maximized)); | 130 &is_maximized)); |
| 133 EXPECT_EQ(is_maximized, is_window_maximized); | 131 EXPECT_EQ(is_maximized, is_window_maximized); |
| 134 } | 132 } |
| 135 #endif | 133 #endif |
| OLD | NEW |