| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "app/gfx/chrome_canvas.h" | 5 #include "app/gfx/canvas.h" |
| 6 #include "app/gfx/path.h" | 6 #include "app/gfx/path.h" |
| 7 #include "base/clipboard.h" | 7 #include "base/clipboard.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "views/background.h" | 10 #include "views/background.h" |
| 11 #include "views/controls/button/checkbox.h" | 11 #include "views/controls/button/checkbox.h" |
| 12 #if defined(OS_WIN) | 12 #if defined(OS_WIN) |
| 13 #include "views/controls/button/native_button_win.h" | 13 #include "views/controls/button/native_button_win.h" |
| 14 #endif | 14 #endif |
| 15 #include "views/controls/scroll_view.h" | 15 #include "views/controls/scroll_view.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 41 }; | 41 }; |
| 42 | 42 |
| 43 // Paints the RootView. | 43 // Paints the RootView. |
| 44 void PaintRootView(views::RootView* root, bool empty_paint) { | 44 void PaintRootView(views::RootView* root, bool empty_paint) { |
| 45 if (!empty_paint) { | 45 if (!empty_paint) { |
| 46 root->PaintNow(); | 46 root->PaintNow(); |
| 47 } else { | 47 } else { |
| 48 // User isn't logged in, so that PaintNow will generate an empty rectangle. | 48 // User isn't logged in, so that PaintNow will generate an empty rectangle. |
| 49 // Invoke paint directly. | 49 // Invoke paint directly. |
| 50 gfx::Rect paint_rect = root->GetScheduledPaintRect(); | 50 gfx::Rect paint_rect = root->GetScheduledPaintRect(); |
| 51 ChromeCanvas canvas(paint_rect.width(), paint_rect.height(), true); | 51 gfx::Canvas canvas(paint_rect.width(), paint_rect.height(), true); |
| 52 canvas.TranslateInt(-paint_rect.x(), -paint_rect.y()); | 52 canvas.TranslateInt(-paint_rect.x(), -paint_rect.y()); |
| 53 canvas.ClipRectInt(0, 0, paint_rect.width(), paint_rect.height()); | 53 canvas.ClipRectInt(0, 0, paint_rect.width(), paint_rect.height()); |
| 54 root->ProcessPaint(&canvas); | 54 root->ProcessPaint(&canvas); |
| 55 } | 55 } |
| 56 } | 56 } |
| 57 | 57 |
| 58 /* | 58 /* |
| 59 typedef CWinTraits<WS_VISIBLE|WS_CLIPCHILDREN|WS_CLIPSIBLINGS> CVTWTraits; | 59 typedef CWinTraits<WS_VISIBLE|WS_CLIPCHILDREN|WS_CLIPSIBLINGS> CVTWTraits; |
| 60 | 60 |
| 61 // A trivial window implementation that tracks whether or not it has been | 61 // A trivial window implementation that tracks whether or not it has been |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 location_.y = 0; | 124 location_.y = 0; |
| 125 last_clip_.setEmpty(); | 125 last_clip_.setEmpty(); |
| 126 } | 126 } |
| 127 | 127 |
| 128 virtual void DidChangeBounds(const gfx::Rect& previous, | 128 virtual void DidChangeBounds(const gfx::Rect& previous, |
| 129 const gfx::Rect& current); | 129 const gfx::Rect& current); |
| 130 virtual void ViewHierarchyChanged(bool is_add, View *parent, View *child); | 130 virtual void ViewHierarchyChanged(bool is_add, View *parent, View *child); |
| 131 virtual bool OnMousePressed(const MouseEvent& event); | 131 virtual bool OnMousePressed(const MouseEvent& event); |
| 132 virtual bool OnMouseDragged(const MouseEvent& event); | 132 virtual bool OnMouseDragged(const MouseEvent& event); |
| 133 virtual void OnMouseReleased(const MouseEvent& event, bool canceled); | 133 virtual void OnMouseReleased(const MouseEvent& event, bool canceled); |
| 134 virtual void Paint(ChromeCanvas* canvas); | 134 virtual void Paint(gfx::Canvas* canvas); |
| 135 | 135 |
| 136 // DidChangeBounds test | 136 // DidChangeBounds test |
| 137 bool did_change_bounds_; | 137 bool did_change_bounds_; |
| 138 gfx::Rect previous_bounds_; | 138 gfx::Rect previous_bounds_; |
| 139 gfx::Rect new_bounds_; | 139 gfx::Rect new_bounds_; |
| 140 | 140 |
| 141 // AddRemoveNotifications test | 141 // AddRemoveNotifications test |
| 142 bool child_added_; | 142 bool child_added_; |
| 143 bool child_removed_; | 143 bool child_removed_; |
| 144 View* parent_; | 144 View* parent_; |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 // Make sure v1 did not receive the event | 343 // Make sure v1 did not receive the event |
| 344 EXPECT_EQ(v1->last_mouse_event_type_, 0); | 344 EXPECT_EQ(v1->last_mouse_event_type_, 0); |
| 345 | 345 |
| 346 window.CloseNow(); | 346 window.CloseNow(); |
| 347 } | 347 } |
| 348 | 348 |
| 349 //////////////////////////////////////////////////////////////////////////////// | 349 //////////////////////////////////////////////////////////////////////////////// |
| 350 // Painting | 350 // Painting |
| 351 //////////////////////////////////////////////////////////////////////////////// | 351 //////////////////////////////////////////////////////////////////////////////// |
| 352 | 352 |
| 353 void TestView::Paint(ChromeCanvas* canvas) { | 353 void TestView::Paint(gfx::Canvas* canvas) { |
| 354 canvas->getClipBounds(&last_clip_); | 354 canvas->getClipBounds(&last_clip_); |
| 355 } | 355 } |
| 356 | 356 |
| 357 void CheckRect(const SkRect& check_rect, const SkRect& target_rect) { | 357 void CheckRect(const SkRect& check_rect, const SkRect& target_rect) { |
| 358 EXPECT_EQ(target_rect.fLeft, check_rect.fLeft); | 358 EXPECT_EQ(target_rect.fLeft, check_rect.fLeft); |
| 359 EXPECT_EQ(target_rect.fRight, check_rect.fRight); | 359 EXPECT_EQ(target_rect.fRight, check_rect.fRight); |
| 360 EXPECT_EQ(target_rect.fTop, check_rect.fTop); | 360 EXPECT_EQ(target_rect.fTop, check_rect.fTop); |
| 361 EXPECT_EQ(target_rect.fBottom, check_rect.fBottom); | 361 EXPECT_EQ(target_rect.fBottom, check_rect.fBottom); |
| 362 } | 362 } |
| 363 | 363 |
| (...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 998 SimularePressingEnterAndCheckDefaultButton(OK); | 998 SimularePressingEnterAndCheckDefaultButton(OK); |
| 999 | 999 |
| 1000 // Focus the cancel button. | 1000 // Focus the cancel button. |
| 1001 client_view_->FocusWillChange(NULL, cancel_button_); | 1001 client_view_->FocusWillChange(NULL, cancel_button_); |
| 1002 EXPECT_FALSE(ok_button_->is_default()); | 1002 EXPECT_FALSE(ok_button_->is_default()); |
| 1003 EXPECT_TRUE(cancel_button_->is_default()); | 1003 EXPECT_TRUE(cancel_button_->is_default()); |
| 1004 EXPECT_FALSE(dialog_view_->button1_->is_default()); | 1004 EXPECT_FALSE(dialog_view_->button1_->is_default()); |
| 1005 EXPECT_FALSE(dialog_view_->button2_->is_default()); | 1005 EXPECT_FALSE(dialog_view_->button2_->is_default()); |
| 1006 SimularePressingEnterAndCheckDefaultButton(CANCEL); | 1006 SimularePressingEnterAndCheckDefaultButton(CANCEL); |
| 1007 } | 1007 } |
| OLD | NEW |