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