IDB: Make readonly transactions wait for earlier readwrite transactions
[chromium-blink-merge.git] / content / public / test / render_widget_test.cc
blob9828264436340e253390ef4274c3f844c40bd1f5
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
3 // found in the LICENSE file.
5 #include "content/public/test/render_widget_test.h"
7 #include "base/basictypes.h"
8 #include "base/files/file_path.h"
9 #include "base/files/file_util.h"
10 #include "base/memory/ref_counted_memory.h"
11 #include "base/strings/stringprintf.h"
12 #include "content/common/view_messages.h"
13 #include "content/renderer/render_view_impl.h"
14 #include "testing/gtest/include/gtest/gtest.h"
15 #include "third_party/WebKit/public/platform/WebScreenOrientationType.h"
16 #include "third_party/WebKit/public/platform/WebSize.h"
17 #include "third_party/WebKit/public/web/WebView.h"
18 #include "third_party/skia/include/core/SkBitmap.h"
19 #include "ui/gfx/codec/jpeg_codec.h"
20 #include "ui/gfx/size.h"
21 #include "ui/surface/transport_dib.h"
23 namespace content {
25 const int RenderWidgetTest::kNumBytesPerPixel = 4;
26 const int RenderWidgetTest::kLargeWidth = 1024;
27 const int RenderWidgetTest::kLargeHeight = 768;
28 const int RenderWidgetTest::kSmallWidth = 600;
29 const int RenderWidgetTest::kSmallHeight = 450;
30 const int RenderWidgetTest::kTextPositionX = 800;
31 const int RenderWidgetTest::kTextPositionY = 600;
32 const uint32 RenderWidgetTest::kRedARGB = 0xFFFF0000;
34 RenderWidgetTest::RenderWidgetTest() {}
36 void RenderWidgetTest::TestOnResize() {
37 RenderWidget* widget = static_cast<RenderViewImpl*>(view_);
39 // The initial bounds is empty, so setting it to the same thing should do
40 // nothing.
41 ViewMsg_Resize_Params resize_params;
42 resize_params.screen_info = blink::WebScreenInfo();
43 resize_params.new_size = gfx::Size();
44 resize_params.physical_backing_size = gfx::Size();
45 resize_params.top_controls_layout_height = 0.f;
46 resize_params.resizer_rect = gfx::Rect();
47 resize_params.is_fullscreen = false;
48 widget->OnResize(resize_params);
49 EXPECT_FALSE(widget->next_paint_is_resize_ack());
51 // Setting empty physical backing size should not send the ack.
52 resize_params.new_size = gfx::Size(10, 10);
53 widget->OnResize(resize_params);
54 EXPECT_FALSE(widget->next_paint_is_resize_ack());
56 // Setting the bounds to a "real" rect should send the ack.
57 render_thread_->sink().ClearMessages();
58 gfx::Size size(100, 100);
59 resize_params.new_size = size;
60 resize_params.physical_backing_size = size;
61 widget->OnResize(resize_params);
62 EXPECT_TRUE(widget->next_paint_is_resize_ack());
64 // Clear the flag.
65 // TODO(danakj): How real is this test any more? This flag is only existing
66 // for DCHECKs now.
67 widget->didCompleteSwapBuffers();
69 // Setting the same size again should not send the ack.
70 widget->OnResize(resize_params);
71 EXPECT_FALSE(widget->next_paint_is_resize_ack());
73 // Resetting the rect to empty should not send the ack.
74 resize_params.new_size = gfx::Size();
75 resize_params.physical_backing_size = gfx::Size();
76 widget->OnResize(resize_params);
77 EXPECT_FALSE(widget->next_paint_is_resize_ack());
79 // Changing the screen info should not send the ack.
80 resize_params.screen_info.orientationAngle = 90;
81 widget->OnResize(resize_params);
82 EXPECT_FALSE(widget->next_paint_is_resize_ack());
84 resize_params.screen_info.orientationType =
85 blink::WebScreenOrientationPortraitPrimary;
86 widget->OnResize(resize_params);
87 EXPECT_FALSE(widget->next_paint_is_resize_ack());
90 } // namespace content