Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(154)

Side by Side Diff: chrome/browser/extensions/pack_extension_unittest.cc

Issue 2799883003: Switch from TestBrowserThread to TestBrowserThreadBundle in chrome. (Closed)
Patch Set: fix-string Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/command_line.h" 5 #include "base/command_line.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/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "base/message_loop/message_loop.h"
10 #include "base/path_service.h" 9 #include "base/path_service.h"
11 #include "chrome/browser/extensions/startup_helper.h" 10 #include "chrome/browser/extensions/startup_helper.h"
12 #include "chrome/common/chrome_paths.h" 11 #include "chrome/common/chrome_paths.h"
13 #include "chrome/common/chrome_switches.h" 12 #include "chrome/common/chrome_switches.h"
14 #include "content/public/test/test_browser_thread.h" 13 #include "content/public/test/test_browser_thread_bundle.h"
15 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
16 15
17 namespace extensions { 16 namespace extensions {
18 17
19 // Tests the environment for packing extensions from the command line 18 // Tests the environment for packing extensions from the command line
20 // when using the --pack-extension switch. 19 // when using the --pack-extension switch.
21 class PackExtensionTest : public testing::Test { 20 class PackExtensionTest : public testing::Test {
22 public: 21 public:
23 PackExtensionTest() 22 PackExtensionTest() {
24 : ui_thread_(content::BrowserThread::UI, &message_loop_),
25 file_thread_(content::BrowserThread::FILE, &message_loop_) {
26 PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir_); 23 PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir_);
27 test_data_dir_ = test_data_dir_.AppendASCII("extensions"); 24 test_data_dir_ = test_data_dir_.AppendASCII("extensions");
28 } 25 }
29 26
30 protected: 27 protected:
31 bool TestPackExtension(const base::FilePath& path) { 28 bool TestPackExtension(const base::FilePath& path) {
32 base::ScopedTempDir temp_dir; 29 base::ScopedTempDir temp_dir;
33 EXPECT_TRUE(temp_dir.CreateUniqueTempDir()); 30 EXPECT_TRUE(temp_dir.CreateUniqueTempDir());
34 EXPECT_TRUE(base::CopyDirectory(path, temp_dir.GetPath(), true)); 31 EXPECT_TRUE(base::CopyDirectory(path, temp_dir.GetPath(), true));
35 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); 32 base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
36 command_line.AppendSwitchPath(switches::kPackExtension, 33 command_line.AppendSwitchPath(switches::kPackExtension,
37 temp_dir.GetPath().Append(path.BaseName())); 34 temp_dir.GetPath().Append(path.BaseName()));
38 return startup_helper_.PackExtension(command_line); 35 return startup_helper_.PackExtension(command_line);
39 } 36 }
40 37
41 base::MessageLoop message_loop_; 38 content::TestBrowserThreadBundle test_browser_thread_bundle_;
42 content::TestBrowserThread ui_thread_;
43 content::TestBrowserThread file_thread_;
44 39
45 base::FilePath test_data_dir_; 40 base::FilePath test_data_dir_;
46 StartupHelper startup_helper_; 41 StartupHelper startup_helper_;
47 }; 42 };
48 43
49 TEST_F(PackExtensionTest, Extension) { 44 TEST_F(PackExtensionTest, Extension) {
50 ASSERT_TRUE(TestPackExtension(test_data_dir_.AppendASCII("api_test") 45 ASSERT_TRUE(TestPackExtension(test_data_dir_.AppendASCII("api_test")
51 .AppendASCII("tabs") 46 .AppendASCII("tabs")
52 .AppendASCII("basics"))); 47 .AppendASCII("basics")));
53 } 48 }
54 49
55 TEST_F(PackExtensionTest, PackagedApp) { 50 TEST_F(PackExtensionTest, PackagedApp) {
56 ASSERT_TRUE(TestPackExtension(test_data_dir_.AppendASCII("packaged_app"))); 51 ASSERT_TRUE(TestPackExtension(test_data_dir_.AppendASCII("packaged_app")));
57 } 52 }
58 53
59 TEST_F(PackExtensionTest, PlatformApp) { 54 TEST_F(PackExtensionTest, PlatformApp) {
60 ASSERT_TRUE(TestPackExtension(test_data_dir_.AppendASCII("platform_apps") 55 ASSERT_TRUE(TestPackExtension(test_data_dir_.AppendASCII("platform_apps")
61 .AppendASCII("minimal"))); 56 .AppendASCII("minimal")));
62 } 57 }
63 58
64 } // namespace extensions 59 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698