diff options
author | brettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-30 16:41:26 +0000 |
---|---|---|
committer | brettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-30 16:41:26 +0000 |
commit | b8eeb3eeba2418d9a1a7bb8429ddd5ec592298c1 (patch) | |
tree | 3f57eec1b726d23d6126f3f9bcc4c7c86a54da2a /gfx | |
parent | eacaf240e4852d599af41cca2e51279a25c59937 (diff) | |
download | chromium_src-b8eeb3eeba2418d9a1a7bb8429ddd5ec592298c1.zip chromium_src-b8eeb3eeba2418d9a1a7bb8429ddd5ec592298c1.tar.gz chromium_src-b8eeb3eeba2418d9a1a7bb8429ddd5ec592298c1.tar.bz2 |
Restore the Direct2D tests. It no longer uses WindowImpl which I moved to app and caused a circular dependency. Fortunately, this test's requirements are very simple and the code required is very small.
TEST=the tests run
BUG=none
Review URL: http://codereview.chromium.org/6003006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70314 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gfx')
-rw-r--r-- | gfx/DEPS | 3 | ||||
-rw-r--r-- | gfx/canvas_direct2d_unittest.cc | 51 | ||||
-rw-r--r-- | gfx/gfx.gyp | 2 |
3 files changed, 41 insertions, 15 deletions
@@ -2,7 +2,4 @@ include_rules = [ "+base", "+grit/gfx_resources.h", "+skia", - - # Allow the unit tests to use window_impl to pop up windows. - "+app/win/window_impl.h", ] diff --git a/gfx/canvas_direct2d_unittest.cc b/gfx/canvas_direct2d_unittest.cc index 2a50da2..8884f32 100644 --- a/gfx/canvas_direct2d_unittest.cc +++ b/gfx/canvas_direct2d_unittest.cc @@ -7,7 +7,6 @@ #include <vsstyle.h> #include <vssym32.h> -#include "app/win/window_impl.h" #include "base/command_line.h" #include "base/ref_counted_memory.h" #include "base/resource_util.h" @@ -17,6 +16,7 @@ #include "gfx/canvas_skia.h" #include "gfx/codec/png_codec.h" #include "gfx/native_theme_win.h" +#include "gfx/rect.h" #include "gfx/win_util.h" #include "grit/gfx_resources.h" #include "testing/gtest/include/gtest/gtest.h" @@ -25,20 +25,25 @@ namespace { const char kVisibleModeFlag[] = "d2d-canvas-visible"; +const wchar_t kWindowClassName[] = L"GFXD2DTestWindowClass"; -class TestWindow : public app::win::WindowImpl { +class TestWindow { public: static const int kWindowSize = 500; static const int kWindowPosition = 10; - - TestWindow() { + TestWindow() : hwnd_(NULL) { if (CommandLine::ForCurrentProcess()->HasSwitch(kVisibleModeFlag)) Sleep(1000); - // Create the window. - Init(NULL, - gfx::Rect(kWindowPosition, kWindowPosition, kWindowSize, kWindowSize)); + RegisterMyClass(); + + hwnd_ = CreateWindowEx(0, kWindowClassName, NULL, + WS_OVERLAPPEDWINDOW, + kWindowPosition, kWindowPosition, + kWindowSize, kWindowSize, + NULL, NULL, NULL, this); + DCHECK(hwnd_); // Initialize the RenderTarget for the window. rt_ = MakeHWNDRenderTarget(); @@ -50,12 +55,12 @@ class TestWindow : public app::win::WindowImpl { if (CommandLine::ForCurrentProcess()->HasSwitch(kVisibleModeFlag)) Sleep(1000); DestroyWindow(hwnd()); + UnregisterMyClass(); } - ID2D1RenderTarget* rt() const { return rt_.get(); } + HWND hwnd() const { return hwnd_; } - BEGIN_MSG_MAP_EX(TestWindow) - END_MSG_MAP() + ID2D1RenderTarget* rt() const { return rt_.get(); } private: ID2D1RenderTarget* MakeHWNDRenderTarget() { @@ -71,6 +76,30 @@ class TestWindow : public app::win::WindowImpl { return rt; } + void RegisterMyClass() { + WNDCLASSEX class_ex; + class_ex.cbSize = sizeof(WNDCLASSEX); + class_ex.style = CS_DBLCLKS; + class_ex.lpfnWndProc = &DefWindowProc; + class_ex.cbClsExtra = 0; + class_ex.cbWndExtra = 0; + class_ex.hInstance = NULL; + class_ex.hIcon = NULL; + class_ex.hCursor = LoadCursor(NULL, IDC_ARROW); + class_ex.hbrBackground = reinterpret_cast<HBRUSH>(COLOR_BACKGROUND); + class_ex.lpszMenuName = NULL; + class_ex.lpszClassName = kWindowClassName; + class_ex.hIconSm = class_ex.hIcon; + ATOM atom = RegisterClassEx(&class_ex); + DCHECK(atom); + } + + void UnregisterMyClass() { + ::UnregisterClass(kWindowClassName, NULL); + } + + HWND hwnd_; + ScopedComPtr<ID2D1RenderTarget> rt_; DISALLOW_COPY_AND_ASSIGN(TestWindow); @@ -81,7 +110,7 @@ class TestWindow : public app::win::WindowImpl { SkBitmap LoadBitmapFromResources(int resource_id) { SkBitmap bitmap; - HINSTANCE resource_instance = _AtlBaseModule.GetResourceInstance(); + HINSTANCE resource_instance = GetModuleHandle(NULL); void* data_ptr; size_t data_size; if (base::GetDataResourceFromModule(resource_instance, resource_id, &data_ptr, diff --git a/gfx/gfx.gyp b/gfx/gfx.gyp index ada400e..df7d5de 100644 --- a/gfx/gfx.gyp +++ b/gfx/gfx.gyp @@ -42,7 +42,7 @@ ['OS=="win"', { 'sources': [ # TODO(brettw) re-enable this when the dependencies on WindowImpl are fixed! - #'canvas_direct2d_unittest.cc', + 'canvas_direct2d_unittest.cc', 'icon_util_unittest.cc', 'native_theme_win_unittest.cc', ], |