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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "chrome/browser/extensions/extension_install_checker.h" | 8 #include "chrome/browser/extensions/extension_install_checker.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 if (!requirements_error_.empty()) | 53 if (!requirements_error_.empty()) |
54 errors.push_back(requirements_error_); | 54 errors.push_back(requirements_error_); |
55 OnRequirementsCheckDone(sequence_number, errors); | 55 OnRequirementsCheckDone(sequence_number, errors); |
56 } | 56 } |
57 | 57 |
58 void MockCheckBlacklistState(int sequence_number) { | 58 void MockCheckBlacklistState(int sequence_number) { |
59 OnBlacklistStateCheckDone(sequence_number, blacklist_state_); | 59 OnBlacklistStateCheckDone(sequence_number, blacklist_state_); |
60 } | 60 } |
61 | 61 |
62 protected: | 62 protected: |
63 virtual void CheckRequirements() OVERRIDE { | 63 virtual void CheckRequirements() override { |
64 requirements_check_called_ = true; | 64 requirements_check_called_ = true; |
65 MockCheckRequirements(current_sequence_number()); | 65 MockCheckRequirements(current_sequence_number()); |
66 } | 66 } |
67 | 67 |
68 virtual void CheckManagementPolicy() OVERRIDE { | 68 virtual void CheckManagementPolicy() override { |
69 policy_check_called_ = true; | 69 policy_check_called_ = true; |
70 OnManagementPolicyCheckDone(policy_check_error_.empty(), | 70 OnManagementPolicyCheckDone(policy_check_error_.empty(), |
71 policy_check_error_); | 71 policy_check_error_); |
72 } | 72 } |
73 | 73 |
74 virtual void CheckBlacklistState() OVERRIDE { | 74 virtual void CheckBlacklistState() override { |
75 blacklist_check_called_ = true; | 75 blacklist_check_called_ = true; |
76 MockCheckBlacklistState(current_sequence_number()); | 76 MockCheckBlacklistState(current_sequence_number()); |
77 } | 77 } |
78 | 78 |
79 virtual void ResetResults() OVERRIDE { | 79 virtual void ResetResults() override { |
80 ExtensionInstallChecker::ResetResults(); | 80 ExtensionInstallChecker::ResetResults(); |
81 | 81 |
82 requirements_check_called_ = false; | 82 requirements_check_called_ = false; |
83 blacklist_check_called_ = false; | 83 blacklist_check_called_ = false; |
84 policy_check_called_ = false; | 84 policy_check_called_ = false; |
85 } | 85 } |
86 | 86 |
87 bool requirements_check_called_; | 87 bool requirements_check_called_; |
88 bool blacklist_check_called_; | 88 bool blacklist_check_called_; |
89 bool policy_check_called_; | 89 bool policy_check_called_; |
90 | 90 |
91 // Dummy errors for testing. | 91 // Dummy errors for testing. |
92 std::string requirements_error_; | 92 std::string requirements_error_; |
93 std::string policy_check_error_; | 93 std::string policy_check_error_; |
94 BlacklistState blacklist_state_; | 94 BlacklistState blacklist_state_; |
95 }; | 95 }; |
96 | 96 |
97 // This class implements asynchronous mocks of the requirements and blacklist | 97 // This class implements asynchronous mocks of the requirements and blacklist |
98 // checks. | 98 // checks. |
99 class ExtensionInstallCheckerAsync : public ExtensionInstallCheckerForTest { | 99 class ExtensionInstallCheckerAsync : public ExtensionInstallCheckerForTest { |
100 protected: | 100 protected: |
101 virtual void CheckRequirements() OVERRIDE { | 101 virtual void CheckRequirements() override { |
102 requirements_check_called_ = true; | 102 requirements_check_called_ = true; |
103 | 103 |
104 base::MessageLoop::current()->PostTask( | 104 base::MessageLoop::current()->PostTask( |
105 FROM_HERE, | 105 FROM_HERE, |
106 base::Bind(&ExtensionInstallCheckerForTest::MockCheckRequirements, | 106 base::Bind(&ExtensionInstallCheckerForTest::MockCheckRequirements, |
107 base::Unretained(this), | 107 base::Unretained(this), |
108 current_sequence_number())); | 108 current_sequence_number())); |
109 } | 109 } |
110 | 110 |
111 virtual void CheckBlacklistState() OVERRIDE { | 111 virtual void CheckBlacklistState() override { |
112 blacklist_check_called_ = true; | 112 blacklist_check_called_ = true; |
113 | 113 |
114 base::MessageLoop::current()->PostTask( | 114 base::MessageLoop::current()->PostTask( |
115 FROM_HERE, | 115 FROM_HERE, |
116 base::Bind(&ExtensionInstallCheckerForTest::MockCheckBlacklistState, | 116 base::Bind(&ExtensionInstallCheckerForTest::MockCheckBlacklistState, |
117 base::Unretained(this), | 117 base::Unretained(this), |
118 current_sequence_number())); | 118 current_sequence_number())); |
119 } | 119 } |
120 }; | 120 }; |
121 | 121 |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 ExtensionInstallChecker::CHECK_ALL, | 479 ExtensionInstallChecker::CHECK_ALL, |
480 true /* fail fast */, | 480 true /* fail fast */, |
481 base::Bind( | 481 base::Bind( |
482 &ExtensionInstallCheckerMultipleInvocationTest::RunSecondInvocation, | 482 &ExtensionInstallCheckerMultipleInvocationTest::RunSecondInvocation, |
483 base::Unretained(this), | 483 base::Unretained(this), |
484 &checker)); | 484 &checker)); |
485 base::RunLoop().RunUntilIdle(); | 485 base::RunLoop().RunUntilIdle(); |
486 } | 486 } |
487 | 487 |
488 } // namespace extensions | 488 } // namespace extensions |
OLD | NEW |