| 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 const base::FilePath& relative_path, | 97 const base::FilePath& relative_path, |
| 98 bool expected_to_fail); | 98 bool expected_to_fail); |
| 99 | 99 |
| 100 // Wait to see expected jobs. Returns true if we saw all jobs finish as | 100 // Wait to see expected jobs. Returns true if we saw all jobs finish as |
| 101 // expected, or false if any job completed with non-expected success/failure | 101 // expected, or false if any job completed with non-expected success/failure |
| 102 // status. | 102 // status. |
| 103 bool WaitForExpectedJobs(); | 103 bool WaitForExpectedJobs(); |
| 104 | 104 |
| 105 // ContentVerifyJob::TestObserver interface | 105 // ContentVerifyJob::TestObserver interface |
| 106 virtual void JobStarted(const std::string& extension_id, | 106 virtual void JobStarted(const std::string& extension_id, |
| 107 const base::FilePath& relative_path) OVERRIDE; | 107 const base::FilePath& relative_path) override; |
| 108 | 108 |
| 109 virtual void JobFinished(const std::string& extension_id, | 109 virtual void JobFinished(const std::string& extension_id, |
| 110 const base::FilePath& relative_path, | 110 const base::FilePath& relative_path, |
| 111 bool failed) OVERRIDE; | 111 bool failed) override; |
| 112 | 112 |
| 113 private: | 113 private: |
| 114 typedef std::pair<std::string, base::FilePath> ExtensionFile; | 114 typedef std::pair<std::string, base::FilePath> ExtensionFile; |
| 115 typedef std::map<ExtensionFile, bool> ExpectedJobs; | 115 typedef std::map<ExtensionFile, bool> ExpectedJobs; |
| 116 ExpectedJobs expected_jobs_; | 116 ExpectedJobs expected_jobs_; |
| 117 scoped_refptr<content::MessageLoopRunner> loop_runner_; | 117 scoped_refptr<content::MessageLoopRunner> loop_runner_; |
| 118 bool saw_expected_job_results_; | 118 bool saw_expected_job_results_; |
| 119 }; | 119 }; |
| 120 | 120 |
| 121 void JobObserver::ExpectJobResult(const std::string& extension_id, | 121 void JobObserver::ExpectJobResult(const std::string& extension_id, |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 | 249 |
| 250 ASSERT_TRUE(extension); | 250 ASSERT_TRUE(extension); |
| 251 ASSERT_EQ(extension->id(), id); | 251 ASSERT_EQ(extension->id(), id); |
| 252 | 252 |
| 253 EXPECT_TRUE(job_observer.WaitForExpectedJobs()); | 253 EXPECT_TRUE(job_observer.WaitForExpectedJobs()); |
| 254 | 254 |
| 255 ContentVerifyJob::SetObserverForTests(NULL); | 255 ContentVerifyJob::SetObserverForTests(NULL); |
| 256 } | 256 } |
| 257 | 257 |
| 258 } // namespace extensions | 258 } // namespace extensions |
| OLD | NEW |