| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 1516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1527 // enabled or not. | 1527 // enabled or not. |
| 1528 TEST(ExtensionsServiceTestSimple, Enabledness) { | 1528 TEST(ExtensionsServiceTestSimple, Enabledness) { |
| 1529 ExtensionsReadyRecorder recorder; | 1529 ExtensionsReadyRecorder recorder; |
| 1530 TestingProfile profile; | 1530 TestingProfile profile; |
| 1531 MessageLoop loop; | 1531 MessageLoop loop; |
| 1532 scoped_ptr<CommandLine> command_line; | 1532 scoped_ptr<CommandLine> command_line; |
| 1533 scoped_refptr<ExtensionsService> service; | 1533 scoped_refptr<ExtensionsService> service; |
| 1534 FilePath install_dir = profile.GetPath() | 1534 FilePath install_dir = profile.GetPath() |
| 1535 .AppendASCII(ExtensionsService::kInstallDirectoryName); | 1535 .AppendASCII(ExtensionsService::kInstallDirectoryName); |
| 1536 | 1536 |
| 1537 // By default, we are disabled. | 1537 // By default, we are enabled. |
| 1538 command_line.reset(new CommandLine(L"")); | 1538 command_line.reset(new CommandLine(L"")); |
| 1539 service = new ExtensionsService(&profile, command_line.get(), | 1539 service = new ExtensionsService(&profile, command_line.get(), |
| 1540 profile.GetPrefs(), install_dir, &loop, &loop, false); | 1540 profile.GetPrefs(), install_dir, &loop, &loop, false); |
| 1541 EXPECT_FALSE(service->extensions_enabled()); | |
| 1542 service->Init(); | |
| 1543 loop.RunAllPending(); | |
| 1544 EXPECT_TRUE(recorder.ready()); | |
| 1545 | |
| 1546 // If either the command line or pref is set, we are enabled. | |
| 1547 recorder.set_ready(false); | |
| 1548 command_line->AppendSwitch(switches::kEnableExtensions); | |
| 1549 service = new ExtensionsService(&profile, command_line.get(), | |
| 1550 profile.GetPrefs(), install_dir, &loop, &loop, false); | |
| 1551 EXPECT_TRUE(service->extensions_enabled()); | 1541 EXPECT_TRUE(service->extensions_enabled()); |
| 1552 service->Init(); | 1542 service->Init(); |
| 1553 loop.RunAllPending(); | 1543 loop.RunAllPending(); |
| 1554 EXPECT_TRUE(recorder.ready()); | 1544 EXPECT_TRUE(recorder.ready()); |
| 1555 | 1545 |
| 1546 // If either the command line or pref is set, we are disabled. |
| 1556 recorder.set_ready(false); | 1547 recorder.set_ready(false); |
| 1557 profile.GetPrefs()->SetBoolean(prefs::kEnableExtensions, true); | 1548 command_line->AppendSwitch(switches::kDisableExtensions); |
| 1558 service = new ExtensionsService(&profile, command_line.get(), | 1549 service = new ExtensionsService(&profile, command_line.get(), |
| 1559 profile.GetPrefs(), install_dir, &loop, &loop, false); | 1550 profile.GetPrefs(), install_dir, &loop, &loop, false); |
| 1560 EXPECT_TRUE(service->extensions_enabled()); | 1551 EXPECT_FALSE(service->extensions_enabled()); |
| 1561 service->Init(); | 1552 service->Init(); |
| 1562 loop.RunAllPending(); | 1553 loop.RunAllPending(); |
| 1563 EXPECT_TRUE(recorder.ready()); | 1554 EXPECT_FALSE(recorder.ready()); |
| 1555 |
| 1556 recorder.set_ready(false); |
| 1557 profile.GetPrefs()->SetBoolean(prefs::kDisableExtensions, true); |
| 1558 service = new ExtensionsService(&profile, command_line.get(), |
| 1559 profile.GetPrefs(), install_dir, &loop, &loop, false); |
| 1560 EXPECT_FALSE(service->extensions_enabled()); |
| 1561 service->Init(); |
| 1562 loop.RunAllPending(); |
| 1563 EXPECT_FALSE(recorder.ready()); |
| 1564 | 1564 |
| 1565 recorder.set_ready(false); | 1565 recorder.set_ready(false); |
| 1566 command_line.reset(new CommandLine(L"")); | 1566 command_line.reset(new CommandLine(L"")); |
| 1567 service = new ExtensionsService(&profile, command_line.get(), | 1567 service = new ExtensionsService(&profile, command_line.get(), |
| 1568 profile.GetPrefs(), install_dir, &loop, &loop, false); | 1568 profile.GetPrefs(), install_dir, &loop, &loop, false); |
| 1569 EXPECT_TRUE(service->extensions_enabled()); | 1569 EXPECT_FALSE(service->extensions_enabled()); |
| 1570 service->Init(); | 1570 service->Init(); |
| 1571 loop.RunAllPending(); | 1571 loop.RunAllPending(); |
| 1572 EXPECT_TRUE(recorder.ready()); | 1572 EXPECT_FALSE(recorder.ready()); |
| 1573 } | 1573 } |
| OLD | NEW |