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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_aura_unittest.cc

Issue 16048003: Fix race between DPI and window size (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove semicolon Created 7 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/renderer_host/render_widget_host_view_aura.h" 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "content/browser/renderer_host/render_widget_host_delegate.h" 10 #include "content/browser/renderer_host/render_widget_host_delegate.h"
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 sink_->ClearMessages(); 376 sink_->ClearMessages();
377 view_->SetSize(gfx::Size(100, 100)); 377 view_->SetSize(gfx::Size(100, 100));
378 EXPECT_EQ("100x100", view_->GetPhysicalBackingSize().ToString()); 378 EXPECT_EQ("100x100", view_->GetPhysicalBackingSize().ToString());
379 EXPECT_EQ(1u, sink_->message_count()); 379 EXPECT_EQ(1u, sink_->message_count());
380 EXPECT_EQ(ViewMsg_Resize::ID, sink_->GetMessageAt(0)->type()); 380 EXPECT_EQ(ViewMsg_Resize::ID, sink_->GetMessageAt(0)->type());
381 { 381 {
382 const IPC::Message* msg = sink_->GetMessageAt(0); 382 const IPC::Message* msg = sink_->GetMessageAt(0);
383 EXPECT_EQ(ViewMsg_Resize::ID, msg->type()); 383 EXPECT_EQ(ViewMsg_Resize::ID, msg->type());
384 ViewMsg_Resize::Param params; 384 ViewMsg_Resize::Param params;
385 ViewMsg_Resize::Read(msg, &params); 385 ViewMsg_Resize::Read(msg, &params);
386 EXPECT_EQ("100x100", params.a.ToString()); // dip size 386 EXPECT_EQ("100x100", params.a.new_size.ToString()); // dip size
387 EXPECT_EQ("100x100", params.b.ToString()); // backing size 387 EXPECT_EQ("100x100",
388 params.a.physical_backing_size.ToString()); // backing size
388 } 389 }
389 390
390 widget_host_->ResetSizeAndRepaintPendingFlags(); 391 widget_host_->ResetSizeAndRepaintPendingFlags();
391 sink_->ClearMessages(); 392 sink_->ClearMessages();
392 393
393 aura_test_helper_->test_screen()->SetDeviceScaleFactor(2.0f); 394 aura_test_helper_->test_screen()->SetDeviceScaleFactor(2.0f);
394 EXPECT_EQ("200x200", view_->GetPhysicalBackingSize().ToString()); 395 EXPECT_EQ("200x200", view_->GetPhysicalBackingSize().ToString());
395 // Extra ScreenInfoChanged message for |parent_view_|. 396 // Extra ScreenInfoChanged message for |parent_view_|.
396 EXPECT_EQ(3u, sink_->message_count()); 397 EXPECT_EQ(1u, sink_->message_count());
397 EXPECT_EQ(ViewMsg_ScreenInfoChanged::ID, sink_->GetMessageAt(0)->type());
398 { 398 {
399 const IPC::Message* msg = sink_->GetMessageAt(1); 399 const IPC::Message* msg = sink_->GetMessageAt(0);
400 EXPECT_EQ(ViewMsg_ScreenInfoChanged::ID, msg->type());
401 ViewMsg_ScreenInfoChanged::Param params;
402 ViewMsg_ScreenInfoChanged::Read(msg, &params);
403 EXPECT_EQ(2.0f, params.a.deviceScaleFactor);
404 }
405 {
406 const IPC::Message* msg = sink_->GetMessageAt(2);
407 EXPECT_EQ(ViewMsg_Resize::ID, msg->type()); 400 EXPECT_EQ(ViewMsg_Resize::ID, msg->type());
408 ViewMsg_Resize::Param params; 401 ViewMsg_Resize::Param params;
409 ViewMsg_Resize::Read(msg, &params); 402 ViewMsg_Resize::Read(msg, &params);
410 EXPECT_EQ("100x100", params.a.ToString()); // dip size 403 EXPECT_EQ(2.0f, params.a.screen_info.deviceScaleFactor);
411 EXPECT_EQ("200x200", params.b.ToString()); // backing size 404 EXPECT_EQ("100x100", params.a.new_size.ToString()); // dip size
405 EXPECT_EQ("200x200",
406 params.a.physical_backing_size.ToString()); // backing size
412 } 407 }
413 408
414 widget_host_->ResetSizeAndRepaintPendingFlags(); 409 widget_host_->ResetSizeAndRepaintPendingFlags();
415 sink_->ClearMessages(); 410 sink_->ClearMessages();
416 411
417 aura_test_helper_->test_screen()->SetDeviceScaleFactor(1.0f); 412 aura_test_helper_->test_screen()->SetDeviceScaleFactor(1.0f);
418 // Extra ScreenInfoChanged message for |parent_view_|. 413 // Extra ScreenInfoChanged message for |parent_view_|.
419 EXPECT_EQ(3u, sink_->message_count()); 414 EXPECT_EQ(1u, sink_->message_count());
420 EXPECT_EQ("100x100", view_->GetPhysicalBackingSize().ToString()); 415 EXPECT_EQ("100x100", view_->GetPhysicalBackingSize().ToString());
421 EXPECT_EQ(ViewMsg_ScreenInfoChanged::ID, sink_->GetMessageAt(0)->type());
422 { 416 {
423 const IPC::Message* msg = sink_->GetMessageAt(1); 417 const IPC::Message* msg = sink_->GetMessageAt(0);
424 EXPECT_EQ(ViewMsg_ScreenInfoChanged::ID, msg->type());
425 ViewMsg_ScreenInfoChanged::Param params;
426 ViewMsg_ScreenInfoChanged::Read(msg, &params);
427 EXPECT_EQ(1.0f, params.a.deviceScaleFactor);
428 }
429 {
430 const IPC::Message* msg = sink_->GetMessageAt(2);
431 EXPECT_EQ(ViewMsg_Resize::ID, msg->type()); 418 EXPECT_EQ(ViewMsg_Resize::ID, msg->type());
432 ViewMsg_Resize::Param params; 419 ViewMsg_Resize::Param params;
433 ViewMsg_Resize::Read(msg, &params); 420 ViewMsg_Resize::Read(msg, &params);
434 EXPECT_EQ("100x100", params.a.ToString()); // dip size 421 EXPECT_EQ(1.0f, params.a.screen_info.deviceScaleFactor);
435 EXPECT_EQ("100x100", params.b.ToString()); // backing size 422 EXPECT_EQ("100x100", params.a.new_size.ToString()); // dip size
423 EXPECT_EQ("100x100",
424 params.a.physical_backing_size.ToString()); // backing size
436 } 425 }
437 } 426 }
438 427
439 } // namespace content 428 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698