| 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/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 6 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 7 #include "chrome/app/chrome_command_ids.h" | 8 #include "chrome/app/chrome_command_ids.h" |
| 8 #include "chrome/browser/protector/mock_setting_change.h" | 9 #include "chrome/browser/protector/mock_setting_change.h" |
| 9 #include "chrome/browser/protector/protector_service.h" | 10 #include "chrome/browser/protector/protector_service.h" |
| 10 #include "chrome/browser/protector/protector_service_factory.h" | 11 #include "chrome/browser/protector/protector_service_factory.h" |
| 11 #include "chrome/browser/protector/settings_change_global_error.h" | 12 #include "chrome/browser/protector/settings_change_global_error.h" |
| 12 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
| 13 #include "chrome/browser/ui/global_error.h" | 14 #include "chrome/browser/ui/global_error.h" |
| 14 #include "chrome/browser/ui/global_error_bubble_view_base.h" | 15 #include "chrome/browser/ui/global_error_bubble_view_base.h" |
| 15 #include "chrome/browser/ui/global_error_service.h" | 16 #include "chrome/browser/ui/global_error_service.h" |
| 16 #include "chrome/browser/ui/global_error_service_factory.h" | 17 #include "chrome/browser/ui/global_error_service_factory.h" |
| 18 #include "chrome/common/chrome_switches.h" |
| 17 #include "chrome/test/base/in_process_browser_test.h" | 19 #include "chrome/test/base/in_process_browser_test.h" |
| 18 #include "chrome/test/base/ui_test_utils.h" | 20 #include "chrome/test/base/ui_test_utils.h" |
| 19 | 21 |
| 20 using ::testing::InvokeWithoutArgs; | 22 using ::testing::InvokeWithoutArgs; |
| 21 using ::testing::NiceMock; | 23 using ::testing::NiceMock; |
| 22 using ::testing::Return; | 24 using ::testing::Return; |
| 23 | 25 |
| 24 namespace protector { | 26 namespace protector { |
| 25 | 27 |
| 26 class ProtectorServiceTest : public InProcessBrowserTest { | 28 class ProtectorServiceTest : public InProcessBrowserTest { |
| 27 public: | 29 public: |
| 28 virtual void SetUpOnMainThread() { | 30 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 31 // Make sure protector is enabled. |
| 32 command_line->AppendSwitch(switches::kProtector); |
| 33 } |
| 34 |
| 35 virtual void SetUpOnMainThread() OVERRIDE { |
| 29 protector_service_ = | 36 protector_service_ = |
| 30 ProtectorServiceFactory::GetForProfile(browser()->profile()); | 37 ProtectorServiceFactory::GetForProfile(browser()->profile()); |
| 31 // ProtectService will own this change instance. | 38 // ProtectService will own this change instance. |
| 32 mock_change_ = new NiceMock<MockSettingChange>(); | 39 mock_change_ = new NiceMock<MockSettingChange>(); |
| 33 } | 40 } |
| 34 | 41 |
| 35 protected: | 42 protected: |
| 36 GlobalError* GetGlobalError(BaseSettingChange* change) { | 43 GlobalError* GetGlobalError(BaseSettingChange* change) { |
| 37 for (ProtectorService::Items::iterator item = | 44 for (ProtectorService::Items::iterator item = |
| 38 protector_service_->items_.begin(); | 45 protector_service_->items_.begin(); |
| (...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 | 639 |
| 633 protector_service_->DismissChange(composite_change); | 640 protector_service_->DismissChange(composite_change); |
| 634 ui_test_utils::RunAllPendingInMessageLoop(); | 641 ui_test_utils::RunAllPendingInMessageLoop(); |
| 635 EXPECT_FALSE(IsGlobalErrorActive(composite_change)); | 642 EXPECT_FALSE(IsGlobalErrorActive(composite_change)); |
| 636 EXPECT_FALSE(protector_service_->GetLastChange()); | 643 EXPECT_FALSE(protector_service_->GetLastChange()); |
| 637 } | 644 } |
| 638 | 645 |
| 639 // TODO(ivankr): Timeout test. | 646 // TODO(ivankr): Timeout test. |
| 640 | 647 |
| 641 } // namespace protector | 648 } // namespace protector |
| OLD | NEW |