| OLD | NEW |
| 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 "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
| 6 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
| 7 #include "third_party/skia/include/core/SkBitmap.h" | 7 #include "third_party/skia/include/core/SkBitmap.h" |
| 8 #include "ui/gfx/image/image.h" | 8 #include "ui/gfx/image/image.h" |
| 9 #include "ui/gfx/image/image_unittest_util.h" | 9 #include "ui/gfx/image/image_unittest_util.h" |
| 10 | 10 |
| 11 #if defined(TOOLKIT_GTK) | |
| 12 #include <gtk/gtk.h> | |
| 13 | |
| 14 #include "ui/gfx/gtk_util.h" | |
| 15 #endif | |
| 16 | |
| 17 #if defined(TOOLKIT_VIEWS) | 11 #if defined(TOOLKIT_VIEWS) |
| 18 #include "ui/views/controls/image_view.h" | 12 #include "ui/views/controls/image_view.h" |
| 19 #include "ui/views/view.h" | 13 #include "ui/views/view.h" |
| 20 #endif | 14 #endif |
| 21 | 15 |
| 22 namespace { | 16 namespace { |
| 23 | 17 |
| 24 #if defined(TOOLKIT_VIEWS) | 18 #if defined(TOOLKIT_VIEWS) |
| 25 TEST(UiGfxImageTest, ViewsImageView) { | 19 TEST(UiGfxImageTest, ViewsImageView) { |
| 26 gfx::Image image(gfx::test::CreatePlatformImage()); | 20 gfx::Image image(gfx::test::CreatePlatformImage()); |
| 27 | 21 |
| 28 scoped_ptr<views::View> container(new views::View()); | 22 scoped_ptr<views::View> container(new views::View()); |
| 29 container->SetBounds(0, 0, 200, 200); | 23 container->SetBounds(0, 0, 200, 200); |
| 30 container->SetVisible(true); | 24 container->SetVisible(true); |
| 31 | 25 |
| 32 scoped_ptr<views::ImageView> image_view(new views::ImageView()); | 26 scoped_ptr<views::ImageView> image_view(new views::ImageView()); |
| 33 image_view->SetImage(*image.ToImageSkia()); | 27 image_view->SetImage(*image.ToImageSkia()); |
| 34 container->AddChildView(image_view.get()); | 28 container->AddChildView(image_view.get()); |
| 35 } | 29 } |
| 36 #endif | 30 #endif |
| 37 | 31 |
| 38 #if defined(TOOLKIT_GTK) | |
| 39 TEST(UiGfxImageTest, GtkImageView) { | |
| 40 GtkWidget* window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
| 41 gtk_window_resize(GTK_WINDOW(window), 200, 200); | |
| 42 gtk_window_move(GTK_WINDOW(window), 300, 300); | |
| 43 | |
| 44 GtkWidget* fixed = gtk_fixed_new(); | |
| 45 gtk_container_add(GTK_CONTAINER(window), fixed); | |
| 46 | |
| 47 gfx::Image image = gfx::Image::CreateFrom1xBitmap( | |
| 48 gfx::test::CreateBitmap(25, 25)); | |
| 49 GtkWidget* image_view = gtk_image_new_from_pixbuf(image.ToGdkPixbuf()); | |
| 50 gtk_fixed_put(GTK_FIXED(fixed), image_view, 10, 10); | |
| 51 gtk_widget_set_size_request(image_view, 25, 25); | |
| 52 | |
| 53 gtk_widget_show_all(window); | |
| 54 | |
| 55 gtk_widget_destroy(window); | |
| 56 } | |
| 57 #endif | |
| 58 | |
| 59 } // namespace | 32 } // namespace |
| OLD | NEW |