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

Unified Diff: apps/shell_window_geometry_cache_unittest.cc

Issue 21444002: Do not restore corrupt cached app window bounds. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix browser tests Created 7 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
« no previous file with comments | « apps/shell_window_geometry_cache.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: apps/shell_window_geometry_cache_unittest.cc
diff --git a/apps/shell_window_geometry_cache_unittest.cc b/apps/shell_window_geometry_cache_unittest.cc
index 7cc3dac25a93fad68c6d10100eaa3017a314a0bd..98c4bdca5947ccc0a0e9552f53e7b0a39e57becb 100644
--- a/apps/shell_window_geometry_cache_unittest.cc
+++ b/apps/shell_window_geometry_cache_unittest.cc
@@ -141,6 +141,60 @@ TEST_F(ShellWindowGeometryCacheTest, GetGeometryAndStateFromStore) {
ASSERT_EQ(state, new_state);
}
+// Test corrupt bounds will not be loaded.
+TEST_F(ShellWindowGeometryCacheTest, CorruptBounds) {
+ const std::string extension_id = prefs_->AddExtensionAndReturnId("ext1");
+ gfx::Rect bounds;
+ gfx::Rect screen_bounds(0, 0, 1600, 900);
+ ui::WindowShowState state = ui::SHOW_STATE_NORMAL;
+ AddGeometryAndLoadExtension(extension_id, kWindowId, bounds,
+ screen_bounds, state);
+ gfx::Rect new_bounds;
+ gfx::Rect new_screen_bounds;
+ ui::WindowShowState new_state = ui::SHOW_STATE_DEFAULT;
+ ASSERT_FALSE(cache_->GetGeometry(
+ extension_id, kWindowId, &new_bounds, &new_screen_bounds, &new_state));
+ ASSERT_TRUE(new_bounds.IsEmpty());
+ ASSERT_TRUE(new_screen_bounds.IsEmpty());
+ ASSERT_EQ(new_state, ui::SHOW_STATE_DEFAULT);
+}
+
+// Test corrupt screen bounds will not be loaded.
+TEST_F(ShellWindowGeometryCacheTest, CorruptScreenBounds) {
+ const std::string extension_id = prefs_->AddExtensionAndReturnId("ext1");
+ gfx::Rect bounds(4, 5, 31, 43);
+ gfx::Rect screen_bounds;
+ ui::WindowShowState state = ui::SHOW_STATE_NORMAL;
+ AddGeometryAndLoadExtension(extension_id, kWindowId, bounds,
+ screen_bounds, state);
+ gfx::Rect new_bounds;
+ gfx::Rect new_screen_bounds;
+ ui::WindowShowState new_state = ui::SHOW_STATE_DEFAULT;
+ ASSERT_FALSE(cache_->GetGeometry(
+ extension_id, kWindowId, &new_bounds, &new_screen_bounds, &new_state));
+ ASSERT_TRUE(new_bounds.IsEmpty());
+ ASSERT_TRUE(new_screen_bounds.IsEmpty());
+ ASSERT_EQ(new_state, ui::SHOW_STATE_DEFAULT);
+}
+
+// Test corrupt state will not be loaded.
+TEST_F(ShellWindowGeometryCacheTest, CorruptState) {
+ const std::string extension_id = prefs_->AddExtensionAndReturnId("ext1");
+ gfx::Rect bounds(4, 5, 31, 43);
+ gfx::Rect screen_bounds(0, 0, 1600, 900);
+ ui::WindowShowState state = ui::SHOW_STATE_DEFAULT;
+ AddGeometryAndLoadExtension(extension_id, kWindowId, bounds,
+ screen_bounds, state);
+ gfx::Rect new_bounds;
+ gfx::Rect new_screen_bounds;
+ ui::WindowShowState new_state = ui::SHOW_STATE_DEFAULT;
+ ASSERT_FALSE(cache_->GetGeometry(
+ extension_id, kWindowId, &new_bounds, &new_screen_bounds, &new_state));
+ ASSERT_TRUE(new_bounds.IsEmpty());
+ ASSERT_TRUE(new_screen_bounds.IsEmpty());
+ ASSERT_EQ(new_state, ui::SHOW_STATE_DEFAULT);
+}
+
// Test saving geometry, screen_bounds and state to the cache and state store,
// and reading it back.
TEST_F(ShellWindowGeometryCacheTest, SaveGeometryAndStateToStore) {
« no previous file with comments | « apps/shell_window_geometry_cache.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698