| 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 #import "chrome/browser/ui/cocoa/profiles/avatar_menu_bubble_controller.h" | 5 #import "chrome/browser/ui/cocoa/profiles/avatar_menu_bubble_controller.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/mac/scoped_nsobject.h" | 8 #include "base/mac/scoped_nsobject.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/message_loop/message_pump_mac.h" | 10 #include "base/message_loop/message_pump_mac.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "chrome/browser/prefs/pref_service_syncable.h" | 12 #include "chrome/browser/prefs/pref_service_syncable.h" |
| 13 #include "chrome/browser/profiles/avatar_menu.h" | 13 #include "chrome/browser/profiles/avatar_menu.h" |
| 14 #include "chrome/browser/profiles/avatar_menu_observer.h" | 14 #include "chrome/browser/profiles/avatar_menu_observer.h" |
| 15 #include "chrome/browser/profiles/profile_info_cache.h" | 15 #include "chrome/browser/profiles/profile_info_cache.h" |
| 16 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" | 16 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" |
| 17 #include "chrome/test/base/testing_browser_process.h" | 17 #include "chrome/test/base/testing_browser_process.h" |
| 18 #include "chrome/test/base/testing_profile_manager.h" | 18 #include "chrome/test/base/testing_profile_manager.h" |
| 19 #include "components/signin/core/common/profile_management_switches.h" | 19 #include "components/signin/core/common/profile_management_switches.h" |
| 20 #include "content/public/test/test_browser_thread_bundle.h" |
| 20 #include "testing/gtest_mac.h" | 21 #include "testing/gtest_mac.h" |
| 21 #import "ui/base/cocoa/controls/hyperlink_button_cell.h" | 22 #import "ui/base/cocoa/controls/hyperlink_button_cell.h" |
| 22 #include "ui/events/test/cocoa_test_event_utils.h" | 23 #include "ui/events/test/cocoa_test_event_utils.h" |
| 23 | 24 |
| 24 class AvatarMenuBubbleControllerTest : public CocoaTest { | 25 class AvatarMenuBubbleControllerTest : public CocoaTest { |
| 25 public: | 26 public: |
| 26 AvatarMenuBubbleControllerTest() | 27 AvatarMenuBubbleControllerTest() |
| 27 : manager_(TestingBrowserProcess::GetGlobal()) { | 28 : manager_(TestingBrowserProcess::GetGlobal()) { |
| 28 } | 29 } |
| 29 | 30 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 60 | 61 |
| 61 AvatarMenuItemController* GetHighlightedItem() { | 62 AvatarMenuItemController* GetHighlightedItem() { |
| 62 for (AvatarMenuItemController* item in [controller() items]) { | 63 for (AvatarMenuItemController* item in [controller() items]) { |
| 63 if ([item isHighlighted]) | 64 if ([item isHighlighted]) |
| 64 return item; | 65 return item; |
| 65 } | 66 } |
| 66 return nil; | 67 return nil; |
| 67 } | 68 } |
| 68 | 69 |
| 69 private: | 70 private: |
| 71 content::TestBrowserThreadBundle thread_bundle_; |
| 70 TestingProfileManager manager_; | 72 TestingProfileManager manager_; |
| 71 | 73 |
| 72 // Weak; releases self. | 74 // Weak; releases self. |
| 73 AvatarMenuBubbleController* controller_; | 75 AvatarMenuBubbleController* controller_; |
| 74 | 76 |
| 75 // Weak; owned by |controller_|. | 77 // Weak; owned by |controller_|. |
| 76 AvatarMenu* menu_; | 78 AvatarMenu* menu_; |
| 77 }; | 79 }; |
| 78 | 80 |
| 79 TEST_F(AvatarMenuBubbleControllerTest, InitialLayout) { | 81 TEST_F(AvatarMenuBubbleControllerTest, InitialLayout) { |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 [controller() keyDown:event]; | 268 [controller() keyDown:event]; |
| 267 EXPECT_EQ([[controller() items] objectAtIndex:0], GetHighlightedItem()); | 269 EXPECT_EQ([[controller() items] objectAtIndex:0], GetHighlightedItem()); |
| 268 | 270 |
| 269 [controller() keyDown:event]; | 271 [controller() keyDown:event]; |
| 270 EXPECT_EQ([[controller() items] objectAtIndex:1], GetHighlightedItem()); | 272 EXPECT_EQ([[controller() items] objectAtIndex:1], GetHighlightedItem()); |
| 271 | 273 |
| 272 // There are no more items now so going up should stay at the first item. | 274 // There are no more items now so going up should stay at the first item. |
| 273 [controller() keyDown:event]; | 275 [controller() keyDown:event]; |
| 274 EXPECT_EQ([[controller() items] objectAtIndex:1], GetHighlightedItem()); | 276 EXPECT_EQ([[controller() items] objectAtIndex:1], GetHighlightedItem()); |
| 275 } | 277 } |
| OLD | NEW |