Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / tests / ui_gfx_image_unittest.cc
blob756f7d36978e9d26af7eda031850943d4ed4bc5c
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 "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/image.h"
9 #include "ui/gfx/image/image_unittest_util.h"
11 #if defined(TOOLKIT_GTK)
12 #include <gtk/gtk.h>
14 #include "ui/gfx/gtk_util.h"
15 #endif
17 #if defined(TOOLKIT_VIEWS)
18 #include "ui/views/controls/image_view.h"
19 #include "ui/views/view.h"
20 #endif
22 namespace {
24 #if defined(TOOLKIT_VIEWS)
25 TEST(UiGfxImageTest, ViewsImageView) {
26 gfx::Image image(gfx::test::CreatePlatformImage());
28 scoped_ptr<views::View> container(new views::View());
29 container->SetBounds(0, 0, 200, 200);
30 container->SetVisible(true);
32 scoped_ptr<views::ImageView> image_view(new views::ImageView());
33 image_view->SetImage(*image.ToImageSkia());
34 container->AddChildView(image_view.get());
36 #endif
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);
44 GtkWidget* fixed = gtk_fixed_new();
45 gtk_container_add(GTK_CONTAINER(window), fixed);
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);
53 gtk_widget_show_all(window);
55 gtk_widget_destroy(window);
57 #endif
59 } // namespace