| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/ui/views/status_icons/status_tray_state_changer_win.h" | 5 #include "chrome/browser/ui/views/status_icons/status_tray_state_changer_win.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/win/scoped_com_initializer.h" | 8 #include "base/win/scoped_com_initializer.h" |
| 9 #include "base/win/windows_version.h" | 9 #include "base/win/windows_version.h" |
| 10 #include "chrome/browser/status_icons/status_icon.h" | 10 #include "chrome/browser/status_icons/status_icon.h" |
| 11 #include "chrome/browser/ui/views/status_icons/status_icon_win.h" | 11 #include "chrome/browser/ui/views/status_icons/status_icon_win.h" |
| 12 #include "chrome/browser/ui/views/status_icons/status_tray_win.h" | 12 #include "chrome/browser/ui/views/status_icons/status_tray_win.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include "third_party/skia/include/core/SkBitmap.h" | 14 #include "third_party/skia/include/core/SkBitmap.h" |
| 15 #include "ui/gfx/image/image_skia.h" | 15 #include "ui/gfx/image/image_skia.h" |
| 16 | 16 |
| 17 class StatusTrayStateChangerWinTest : public testing::Test { | 17 class StatusTrayStateChangerWinTest : public testing::Test { |
| 18 public: | 18 public: |
| 19 StatusTrayStateChangerWinTest() {} | 19 StatusTrayStateChangerWinTest() {} |
| 20 | 20 |
| 21 void SetUp() OVERRIDE { | 21 void SetUp() override { |
| 22 testing::Test::SetUp(); | 22 testing::Test::SetUp(); |
| 23 com_.reset(new base::win::ScopedCOMInitializer()); | 23 com_.reset(new base::win::ScopedCOMInitializer()); |
| 24 status_tray_.reset(new StatusTrayWin()); | 24 status_tray_.reset(new StatusTrayWin()); |
| 25 SkBitmap bitmap; | 25 SkBitmap bitmap; |
| 26 | 26 |
| 27 // Put a real bitmap into "bitmap". 2x2 bitmap of green 32 bit pixels. | 27 // Put a real bitmap into "bitmap". 2x2 bitmap of green 32 bit pixels. |
| 28 bitmap.allocN32Pixels(16, 16); | 28 bitmap.allocN32Pixels(16, 16); |
| 29 bitmap.eraseColor(SK_ColorGREEN); | 29 bitmap.eraseColor(SK_ColorGREEN); |
| 30 status_icon_win_ = (StatusIconWin*)status_tray_->CreateStatusIcon( | 30 status_icon_win_ = (StatusIconWin*)status_tray_->CreateStatusIcon( |
| 31 StatusTray::OTHER_ICON, | 31 StatusTray::OTHER_ICON, |
| 32 gfx::ImageSkia::CreateFrom1xBitmap(bitmap), | 32 gfx::ImageSkia::CreateFrom1xBitmap(bitmap), |
| 33 base::string16()); | 33 base::string16()); |
| 34 tray_watcher_ = new StatusTrayStateChangerWin(status_icon_win_->icon_id(), | 34 tray_watcher_ = new StatusTrayStateChangerWin(status_icon_win_->icon_id(), |
| 35 status_icon_win_->window()); | 35 status_icon_win_->window()); |
| 36 } | 36 } |
| 37 | 37 |
| 38 void TearDown() OVERRIDE { | 38 void TearDown() override { |
| 39 tray_watcher_ = NULL; | 39 tray_watcher_ = NULL; |
| 40 status_tray_.reset(); | 40 status_tray_.reset(); |
| 41 com_.reset(); | 41 com_.reset(); |
| 42 testing::Test::TearDown(); | 42 testing::Test::TearDown(); |
| 43 } | 43 } |
| 44 | 44 |
| 45 protected: | 45 protected: |
| 46 HWND icon_window() { return status_icon_win_->window(); } | 46 HWND icon_window() { return status_icon_win_->window(); } |
| 47 UINT icon_id() { return status_icon_win_->icon_id(); } | 47 UINT icon_id() { return status_icon_win_->icon_id(); } |
| 48 | 48 |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 | 158 |
| 159 LONG new_width = new_tray_notify_rect.right - new_tray_notify_rect.left; | 159 LONG new_width = new_tray_notify_rect.right - new_tray_notify_rect.left; |
| 160 | 160 |
| 161 EXPECT_GT(new_width, width); | 161 EXPECT_GT(new_width, width); |
| 162 | 162 |
| 163 SendNotifyItemUpdate(notify_item.Pass()); | 163 SendNotifyItemUpdate(notify_item.Pass()); |
| 164 ::GetWindowRect(tray_notify_hwnd, &new_tray_notify_rect); | 164 ::GetWindowRect(tray_notify_hwnd, &new_tray_notify_rect); |
| 165 new_width = new_tray_notify_rect.right - new_tray_notify_rect.left; | 165 new_width = new_tray_notify_rect.right - new_tray_notify_rect.left; |
| 166 EXPECT_EQ(width, new_width); | 166 EXPECT_EQ(width, new_width); |
| 167 } | 167 } |
| OLD | NEW |