OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/files/file_path.h" | 6 #include "base/files/file_path.h" |
7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
11 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
12 #include "base/threading/sequenced_worker_pool.h" | 12 #include "base/threading/sequenced_worker_pool.h" |
13 #include "chrome/common/chrome_paths.h" | |
14 #include "components/component_updater/crx_downloader.h" | 13 #include "components/component_updater/crx_downloader.h" |
15 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
16 #include "content/public/test/test_browser_thread_bundle.h" | 15 #include "content/public/test/test_browser_thread_bundle.h" |
17 #include "content/test/net/url_request_prepackaged_interceptor.h" | 16 #include "content/test/net/url_request_prepackaged_interceptor.h" |
18 #include "net/base/net_errors.h" | 17 #include "net/base/net_errors.h" |
19 #include "net/url_request/url_request_test_util.h" | 18 #include "net/url_request/url_request_test_util.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
21 | 20 |
22 using content::BrowserThread; | 21 using content::BrowserThread; |
23 using base::ContentsEqual; | 22 using base::ContentsEqual; |
24 | 23 |
25 namespace component_updater { | 24 namespace component_updater { |
26 | 25 |
27 namespace { | 26 namespace { |
28 | 27 |
29 // Intercepts HTTP GET requests sent to "localhost". | 28 // Intercepts HTTP GET requests sent to "localhost". |
30 typedef content::URLLocalHostRequestPrepackagedInterceptor GetInterceptor; | 29 typedef content::URLLocalHostRequestPrepackagedInterceptor GetInterceptor; |
31 | 30 |
32 const char kTestFileName[] = "jebgalgnebhfojomionfpkfelancnnkf.crx"; | 31 const char kTestFileName[] = "jebgalgnebhfojomionfpkfelancnnkf.crx"; |
33 | 32 |
34 base::FilePath MakeTestFilePath(const char* file) { | 33 base::FilePath MakeTestFilePath(const char* file) { |
35 base::FilePath path; | 34 base::FilePath path; |
36 PathService::Get(chrome::DIR_TEST_DATA, &path); | 35 PathService::Get(base::DIR_SOURCE_ROOT, &path); |
37 return path.AppendASCII("components").AppendASCII(file); | 36 return path.AppendASCII("components").AppendASCII("test").AppendASCII("data") |
| 37 .AppendASCII("component_updater").AppendASCII(file); |
38 } | 38 } |
39 | 39 |
40 } // namespace | 40 } // namespace |
41 | 41 |
42 class CrxDownloaderTest : public testing::Test { | 42 class CrxDownloaderTest : public testing::Test { |
43 public: | 43 public: |
44 CrxDownloaderTest(); | 44 CrxDownloaderTest(); |
45 virtual ~CrxDownloaderTest(); | 45 virtual ~CrxDownloaderTest(); |
46 | 46 |
47 // Overrides from testing::Test. | 47 // Overrides from testing::Test. |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 | 374 |
375 EXPECT_EQ(0, interceptor.GetHitCount()); | 375 EXPECT_EQ(0, interceptor.GetHitCount()); |
376 | 376 |
377 EXPECT_EQ(1, num_download_complete_calls_); | 377 EXPECT_EQ(1, num_download_complete_calls_); |
378 EXPECT_EQ(kExpectedContext, crx_context_); | 378 EXPECT_EQ(kExpectedContext, crx_context_); |
379 EXPECT_NE(0, download_complete_result_.error); | 379 EXPECT_NE(0, download_complete_result_.error); |
380 EXPECT_TRUE(download_complete_result_.response.empty()); | 380 EXPECT_TRUE(download_complete_result_.response.empty()); |
381 } | 381 } |
382 | 382 |
383 } // namespace component_updater | 383 } // namespace component_updater |
OLD | NEW |