| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/mac/scoped_nsobject.h" | 6 #include "base/mac/scoped_nsobject.h" |
| 7 #include "base/strings/sys_string_conversions.h" | 7 #include "base/strings/sys_string_conversions.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
| 10 #include "chrome/browser/sync/glue/local_device_info_provider_mock.h" | |
| 11 #include "chrome/browser/sync/profile_sync_service_factory.h" | 10 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 12 #include "chrome/browser/sync/sessions/sessions_sync_manager.h" | 11 #include "chrome/browser/sync/sessions/sessions_sync_manager.h" |
| 13 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" | 12 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" |
| 14 #include "chrome/browser/ui/cocoa/run_loop_testing.h" | 13 #include "chrome/browser/ui/cocoa/run_loop_testing.h" |
| 15 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" | 14 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" |
| 16 #import "chrome/browser/ui/cocoa/view_resizer_pong.h" | 15 #import "chrome/browser/ui/cocoa/view_resizer_pong.h" |
| 17 #import "chrome/browser/ui/cocoa/wrench_menu/wrench_menu_controller.h" | 16 #import "chrome/browser/ui/cocoa/wrench_menu/wrench_menu_controller.h" |
| 18 #include "chrome/browser/ui/toolbar/recent_tabs_builder_test_helper.h" | 17 #include "chrome/browser/ui/toolbar/recent_tabs_builder_test_helper.h" |
| 19 #include "chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.h" | 18 #include "chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.h" |
| 20 #include "chrome/browser/ui/toolbar/wrench_menu_model.h" | 19 #include "chrome/browser/ui/toolbar/wrench_menu_model.h" |
| 21 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
| 22 #include "chrome/grit/generated_resources.h" | 21 #include "chrome/grit/generated_resources.h" |
| 23 #include "chrome/test/base/testing_profile.h" | 22 #include "chrome/test/base/testing_profile.h" |
| 23 #include "components/sync_driver/local_device_info_provider_mock.h" |
| 24 #include "grit/theme_resources.h" | 24 #include "grit/theme_resources.h" |
| 25 #include "sync/api/fake_sync_change_processor.h" | 25 #include "sync/api/fake_sync_change_processor.h" |
| 26 #include "sync/api/sync_error_factory_mock.h" | 26 #include "sync/api/sync_error_factory_mock.h" |
| 27 #include "testing/gmock/include/gmock/gmock.h" | 27 #include "testing/gmock/include/gmock/gmock.h" |
| 28 #include "testing/gtest/include/gtest/gtest.h" | 28 #include "testing/gtest/include/gtest/gtest.h" |
| 29 #include "testing/gtest_mac.h" | 29 #include "testing/gtest_mac.h" |
| 30 #include "testing/platform_test.h" | 30 #include "testing/platform_test.h" |
| 31 #include "ui/base/l10n/l10n_util.h" | 31 #include "ui/base/l10n/l10n_util.h" |
| 32 #include "ui/base/resource/resource_bundle.h" | 32 #include "ui/base/resource/resource_bundle.h" |
| 33 | 33 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 53 virtual ~DummyRouter() {} | 53 virtual ~DummyRouter() {} |
| 54 virtual void StartRoutingTo( | 54 virtual void StartRoutingTo( |
| 55 browser_sync::LocalSessionEventHandler* handler) OVERRIDE {} | 55 browser_sync::LocalSessionEventHandler* handler) OVERRIDE {} |
| 56 virtual void Stop() OVERRIDE {} | 56 virtual void Stop() OVERRIDE {} |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 class WrenchMenuControllerTest | 59 class WrenchMenuControllerTest |
| 60 : public CocoaProfileTest { | 60 : public CocoaProfileTest { |
| 61 public: | 61 public: |
| 62 WrenchMenuControllerTest() | 62 WrenchMenuControllerTest() |
| 63 : local_device_(new browser_sync::LocalDeviceInfoProviderMock( | 63 : local_device_(new sync_driver::LocalDeviceInfoProviderMock( |
| 64 "WrenchMenuControllerTest", | 64 "WrenchMenuControllerTest", |
| 65 "Test Machine", | 65 "Test Machine", |
| 66 "Chromium 10k", | 66 "Chromium 10k", |
| 67 "Chrome 10k", | 67 "Chrome 10k", |
| 68 sync_pb::SyncEnums_DeviceType_TYPE_LINUX, | 68 sync_pb::SyncEnums_DeviceType_TYPE_LINUX, |
| 69 "device_id")) { | 69 "device_id")) { |
| 70 } | 70 } |
| 71 | 71 |
| 72 virtual ~WrenchMenuControllerTest() {} | 72 virtual ~WrenchMenuControllerTest() {} |
| 73 | 73 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 WrenchMenuController* controller() { | 110 WrenchMenuController* controller() { |
| 111 return controller_.get(); | 111 return controller_.get(); |
| 112 } | 112 } |
| 113 | 113 |
| 114 base::scoped_nsobject<WrenchMenuController> controller_; | 114 base::scoped_nsobject<WrenchMenuController> controller_; |
| 115 | 115 |
| 116 scoped_ptr<MockWrenchMenuModel> fake_model_; | 116 scoped_ptr<MockWrenchMenuModel> fake_model_; |
| 117 | 117 |
| 118 private: | 118 private: |
| 119 scoped_ptr<browser_sync::SessionsSyncManager> manager_; | 119 scoped_ptr<browser_sync::SessionsSyncManager> manager_; |
| 120 scoped_ptr<browser_sync::LocalDeviceInfoProviderMock> local_device_; | 120 scoped_ptr<sync_driver::LocalDeviceInfoProviderMock> local_device_; |
| 121 }; | 121 }; |
| 122 | 122 |
| 123 TEST_F(WrenchMenuControllerTest, Initialized) { | 123 TEST_F(WrenchMenuControllerTest, Initialized) { |
| 124 EXPECT_TRUE([controller() menu]); | 124 EXPECT_TRUE([controller() menu]); |
| 125 EXPECT_GE([[controller() menu] numberOfItems], 5); | 125 EXPECT_GE([[controller() menu] numberOfItems], 5); |
| 126 } | 126 } |
| 127 | 127 |
| 128 TEST_F(WrenchMenuControllerTest, DispatchSimple) { | 128 TEST_F(WrenchMenuControllerTest, DispatchSimple) { |
| 129 base::scoped_nsobject<NSButton> button([[NSButton alloc] init]); | 129 base::scoped_nsobject<NSButton> button([[NSButton alloc] init]); |
| 130 [button setTag:IDC_ZOOM_PLUS]; | 130 [button setTag:IDC_ZOOM_PLUS]; |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 } | 232 } |
| 233 | 233 |
| 234 // Verify that |RecentTabsMenuModelDelegate| is deleted before the model | 234 // Verify that |RecentTabsMenuModelDelegate| is deleted before the model |
| 235 // it's observing. | 235 // it's observing. |
| 236 TEST_F(WrenchMenuControllerTest, RecentTabDeleteOrder) { | 236 TEST_F(WrenchMenuControllerTest, RecentTabDeleteOrder) { |
| 237 [controller_ menuNeedsUpdate:[controller_ menu]]; | 237 [controller_ menuNeedsUpdate:[controller_ menu]]; |
| 238 // If the delete order is wrong then the test will crash on exit. | 238 // If the delete order is wrong then the test will crash on exit. |
| 239 } | 239 } |
| 240 | 240 |
| 241 } // namespace | 241 } // namespace |
| OLD | NEW |