| OLD | NEW |
| 1 // Copyright (c) 2011 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) | 11 #if defined(TOOLKIT_GTK) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 #if defined(TOOLKIT_VIEWS) | 24 #if defined(TOOLKIT_VIEWS) |
| 25 TEST(UiGfxImageTest, ViewsImageView) { | 25 TEST(UiGfxImageTest, ViewsImageView) { |
| 26 gfx::Image image(gfx::test::CreatePlatformImage()); | 26 gfx::Image image(gfx::test::CreatePlatformImage()); |
| 27 | 27 |
| 28 scoped_ptr<views::View> container(new views::View()); | 28 scoped_ptr<views::View> container(new views::View()); |
| 29 container->SetBounds(0, 0, 200, 200); | 29 container->SetBounds(0, 0, 200, 200); |
| 30 container->SetVisible(true); | 30 container->SetVisible(true); |
| 31 | 31 |
| 32 scoped_ptr<views::ImageView> image_view(new views::ImageView()); | 32 scoped_ptr<views::ImageView> image_view(new views::ImageView()); |
| 33 image_view->SetImage(*image.ToSkBitmap()); | 33 image_view->SetImage(*image.ToImageSkia()); |
| 34 container->AddChildView(image_view.get()); | 34 container->AddChildView(image_view.get()); |
| 35 } | 35 } |
| 36 #endif | 36 #endif |
| 37 | 37 |
| 38 #if defined(TOOLKIT_GTK) | 38 #if defined(TOOLKIT_GTK) |
| 39 TEST(UiGfxImageTest, GtkImageView) { | 39 TEST(UiGfxImageTest, GtkImageView) { |
| 40 GtkWidget* window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | 40 GtkWidget* window = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
| 41 gtk_window_resize(GTK_WINDOW(window), 200, 200); | 41 gtk_window_resize(GTK_WINDOW(window), 200, 200); |
| 42 gtk_window_move(GTK_WINDOW(window), 300, 300); | 42 gtk_window_move(GTK_WINDOW(window), 300, 300); |
| 43 | 43 |
| 44 GtkWidget* fixed = gtk_fixed_new(); | 44 GtkWidget* fixed = gtk_fixed_new(); |
| 45 gtk_container_add(GTK_CONTAINER(window), fixed); | 45 gtk_container_add(GTK_CONTAINER(window), fixed); |
| 46 | 46 |
| 47 gfx::Image image(gfx::test::CreateBitmap(25, 25)); | 47 gfx::Image image(gfx::test::CreateBitmap(25, 25)); |
| 48 GtkWidget* image_view = gtk_image_new_from_pixbuf(image.ToGdkPixbuf()); | 48 GtkWidget* image_view = gtk_image_new_from_pixbuf(image.ToGdkPixbuf()); |
| 49 gtk_fixed_put(GTK_FIXED(fixed), image_view, 10, 10); | 49 gtk_fixed_put(GTK_FIXED(fixed), image_view, 10, 10); |
| 50 gtk_widget_set_size_request(image_view, 25, 25); | 50 gtk_widget_set_size_request(image_view, 25, 25); |
| 51 | 51 |
| 52 gtk_widget_show_all(window); | 52 gtk_widget_show_all(window); |
| 53 | 53 |
| 54 gtk_widget_destroy(window); | 54 gtk_widget_destroy(window); |
| 55 } | 55 } |
| 56 #endif | 56 #endif |
| 57 | 57 |
| 58 } // namespace | 58 } // namespace |
| OLD | NEW |