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/scoped_observer.h" | 5 #include "base/scoped_observer.h" |
6 #include "chrome/browser/extensions/extension_browsertest.h" | 6 #include "chrome/browser/extensions/extension_browsertest.h" |
7 #include "chrome/common/chrome_switches.h" | 7 #include "chrome/common/chrome_switches.h" |
8 #include "content/public/test/test_utils.h" | 8 #include "content/public/test/test_utils.h" |
9 #include "extensions/browser/content_verify_job.h" | 9 #include "extensions/browser/content_verify_job.h" |
10 #include "extensions/browser/extension_prefs.h" | 10 #include "extensions/browser/extension_prefs.h" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 delegate_.set_id(id_); | 114 delegate_.set_id(id_); |
115 ContentVerifyJob::SetDelegateForTests(&delegate_); | 115 ContentVerifyJob::SetDelegateForTests(&delegate_); |
116 } | 116 } |
117 | 117 |
118 virtual void TearDownOnMainThread() OVERRIDE { | 118 virtual void TearDownOnMainThread() OVERRIDE { |
119 ContentVerifyJob::SetDelegateForTests(NULL); | 119 ContentVerifyJob::SetDelegateForTests(NULL); |
120 ExtensionBrowserTest::TearDownOnMainThread(); | 120 ExtensionBrowserTest::TearDownOnMainThread(); |
121 } | 121 } |
122 | 122 |
123 virtual void OpenPageAndWaitForUnload() { | 123 virtual void OpenPageAndWaitForUnload() { |
124 AddTabAtIndex(1, page_url_, content::PAGE_TRANSITION_LINK); | 124 AddTabAtIndex(1, page_url_, ui::PAGE_TRANSITION_LINK); |
125 unload_observer_->WaitForUnload(id_); | 125 unload_observer_->WaitForUnload(id_); |
126 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile()); | 126 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile()); |
127 int reasons = prefs->GetDisableReasons(id_); | 127 int reasons = prefs->GetDisableReasons(id_); |
128 EXPECT_TRUE(reasons & Extension::DISABLE_CORRUPTED); | 128 EXPECT_TRUE(reasons & Extension::DISABLE_CORRUPTED); |
129 | 129 |
130 // This needs to happen before the ExtensionRegistry gets deleted, which | 130 // This needs to happen before the ExtensionRegistry gets deleted, which |
131 // happens before TearDownOnMainThread is called. | 131 // happens before TearDownOnMainThread is called. |
132 unload_observer_.reset(); | 132 unload_observer_.reset(); |
133 } | 133 } |
134 | 134 |
135 protected: | 135 protected: |
136 JobDelegate delegate_; | 136 JobDelegate delegate_; |
137 scoped_ptr<UnloadObserver> unload_observer_; | 137 scoped_ptr<UnloadObserver> unload_observer_; |
138 ExtensionId id_; | 138 ExtensionId id_; |
139 GURL page_url_; | 139 GURL page_url_; |
140 }; | 140 }; |
141 | 141 |
142 IN_PROC_BROWSER_TEST_F(ContentVerifierTest, FailOnRead) { | 142 IN_PROC_BROWSER_TEST_F(ContentVerifierTest, FailOnRead) { |
143 delegate_.fail_next_read(); | 143 delegate_.fail_next_read(); |
144 OpenPageAndWaitForUnload(); | 144 OpenPageAndWaitForUnload(); |
145 } | 145 } |
146 | 146 |
147 IN_PROC_BROWSER_TEST_F(ContentVerifierTest, FailOnDone) { | 147 IN_PROC_BROWSER_TEST_F(ContentVerifierTest, FailOnDone) { |
148 delegate_.fail_next_done(); | 148 delegate_.fail_next_done(); |
149 OpenPageAndWaitForUnload(); | 149 OpenPageAndWaitForUnload(); |
150 } | 150 } |
151 | 151 |
152 } // namespace extensions | 152 } // namespace extensions |
OLD | NEW |