OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 #include "components/metrics/metrics_pref_names.h" | 45 #include "components/metrics/metrics_pref_names.h" |
46 #include "components/prefs/pref_service.h" | 46 #include "components/prefs/pref_service.h" |
47 #include "content/public/browser/web_contents.h" | 47 #include "content/public/browser/web_contents.h" |
48 #include "content/public/common/content_switches.h" | 48 #include "content/public/common/content_switches.h" |
49 #include "content/public/test/test_utils.h" | 49 #include "content/public/test/test_utils.h" |
50 #include "extensions/browser/extension_system.h" | 50 #include "extensions/browser/extension_system.h" |
51 #include "net/test/embedded_test_server/embedded_test_server.h" | 51 #include "net/test/embedded_test_server/embedded_test_server.h" |
52 #include "testing/gtest/include/gtest/gtest.h" | 52 #include "testing/gtest/include/gtest/gtest.h" |
53 #include "url/gurl.h" | 53 #include "url/gurl.h" |
54 | 54 |
55 #if defined(ENABLE_CONFIGURATION_POLICY) && !defined(OS_CHROMEOS) | 55 #if !defined(OS_CHROMEOS) |
56 #include "base/callback.h" | 56 #include "base/callback.h" |
57 #include "base/run_loop.h" | 57 #include "base/run_loop.h" |
58 #include "base/values.h" | 58 #include "base/values.h" |
59 #include "components/policy/core/browser/browser_policy_connector.h" | 59 #include "components/policy/core/browser/browser_policy_connector.h" |
60 #include "components/policy/core/common/external_data_fetcher.h" | 60 #include "components/policy/core/common/external_data_fetcher.h" |
61 #include "components/policy/core/common/mock_configuration_policy_provider.h" | 61 #include "components/policy/core/common/mock_configuration_policy_provider.h" |
62 #include "components/policy/core/common/policy_map.h" | 62 #include "components/policy/core/common/policy_map.h" |
63 #include "components/policy/core/common/policy_types.h" | 63 #include "components/policy/core/common/policy_types.h" |
64 #include "policy/policy_constants.h" | 64 #include "policy/policy_constants.h" |
65 #include "testing/gmock/include/gmock/gmock.h" | 65 #include "testing/gmock/include/gmock/gmock.h" |
66 | 66 |
67 using testing::_; | 67 using testing::_; |
68 using testing::Return; | 68 using testing::Return; |
69 #endif // defined(ENABLE_CONFIGURATION_POLICY) && !defined(OS_CHROMEOS) | 69 #endif // !defined(OS_CHROMEOS) |
70 | 70 |
71 #if defined(ENABLE_SUPERVISED_USERS) | 71 #if defined(ENABLE_SUPERVISED_USERS) |
72 #include "chrome/browser/supervised_user/supervised_user_navigation_observer.h" | 72 #include "chrome/browser/supervised_user/supervised_user_navigation_observer.h" |
73 #include "chrome/browser/supervised_user/supervised_user_service.h" | 73 #include "chrome/browser/supervised_user/supervised_user_service.h" |
74 #include "chrome/browser/supervised_user/supervised_user_service_factory.h" | 74 #include "chrome/browser/supervised_user/supervised_user_service_factory.h" |
75 #endif | 75 #endif |
76 | 76 |
77 #if defined(OS_WIN) | 77 #if defined(OS_WIN) |
78 #include "base/win/windows_version.h" | 78 #include "base/win/windows_version.h" |
79 #endif | 79 #endif |
(...skipping 1163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1243 const int tab_count = IsWindows10OrNewer() ? 2 : 1; | 1243 const int tab_count = IsWindows10OrNewer() ? 2 : 1; |
1244 EXPECT_EQ(tab_count, tab_strip->count()); | 1244 EXPECT_EQ(tab_count, tab_strip->count()); |
1245 } | 1245 } |
1246 | 1246 |
1247 #endif // !defined(OS_CHROMEOS) | 1247 #endif // !defined(OS_CHROMEOS) |
1248 | 1248 |
1249 // These tests are not applicable to Chrome OS as neither master_preferences nor | 1249 // These tests are not applicable to Chrome OS as neither master_preferences nor |
1250 // the sync promo exist there. | 1250 // the sync promo exist there. |
1251 #if !defined(OS_CHROMEOS) | 1251 #if !defined(OS_CHROMEOS) |
1252 | 1252 |
1253 // On a branded Linux build, policy is required to suppress the first-run | |
1254 // dialog. | |
1255 #if !defined(OS_LINUX) || !defined(GOOGLE_CHROME_BUILD) || \ | |
1256 defined(ENABLE_CONFIGURATION_POLICY) | |
1257 | |
1258 class StartupBrowserCreatorFirstRunTest : public InProcessBrowserTest { | 1253 class StartupBrowserCreatorFirstRunTest : public InProcessBrowserTest { |
1259 protected: | 1254 protected: |
1260 void SetUpCommandLine(base::CommandLine* command_line) override; | 1255 void SetUpCommandLine(base::CommandLine* command_line) override; |
1261 void SetUpInProcessBrowserTestFixture() override; | 1256 void SetUpInProcessBrowserTestFixture() override; |
1262 | 1257 |
1263 // Returns true if the platform supports showing the sync promo on first run. | 1258 // Returns true if the platform supports showing the sync promo on first run. |
1264 static bool PlatformSupportsSyncPromo() { | 1259 static bool PlatformSupportsSyncPromo() { |
1265 return !IsWindows10OrNewer(); | 1260 return !IsWindows10OrNewer(); |
1266 } | 1261 } |
1267 | 1262 |
1268 #if defined(ENABLE_CONFIGURATION_POLICY) | |
1269 policy::MockConfigurationPolicyProvider provider_; | 1263 policy::MockConfigurationPolicyProvider provider_; |
1270 policy::PolicyMap policy_map_; | 1264 policy::PolicyMap policy_map_; |
1271 #endif // defined(ENABLE_CONFIGURATION_POLICY) | |
1272 }; | 1265 }; |
1273 | 1266 |
1274 void StartupBrowserCreatorFirstRunTest::SetUpCommandLine( | 1267 void StartupBrowserCreatorFirstRunTest::SetUpCommandLine( |
1275 base::CommandLine* command_line) { | 1268 base::CommandLine* command_line) { |
1276 command_line->AppendSwitch(switches::kForceFirstRun); | 1269 command_line->AppendSwitch(switches::kForceFirstRun); |
1277 } | 1270 } |
1278 | 1271 |
1279 void StartupBrowserCreatorFirstRunTest::SetUpInProcessBrowserTestFixture() { | 1272 void StartupBrowserCreatorFirstRunTest::SetUpInProcessBrowserTestFixture() { |
1280 #if defined(ENABLE_CONFIGURATION_POLICY) | |
1281 #if defined(OS_LINUX) && defined(GOOGLE_CHROME_BUILD) | 1273 #if defined(OS_LINUX) && defined(GOOGLE_CHROME_BUILD) |
1282 // Set a policy that prevents the first-run dialog from being shown. | 1274 // Set a policy that prevents the first-run dialog from being shown. |
1283 policy_map_.Set(policy::key::kMetricsReportingEnabled, | 1275 policy_map_.Set(policy::key::kMetricsReportingEnabled, |
1284 policy::POLICY_LEVEL_MANDATORY, | 1276 policy::POLICY_LEVEL_MANDATORY, |
1285 policy::POLICY_SCOPE_USER, | 1277 policy::POLICY_SCOPE_USER, |
1286 policy::POLICY_SOURCE_CLOUD, | 1278 policy::POLICY_SOURCE_CLOUD, |
1287 new base::FundamentalValue(false), | 1279 new base::FundamentalValue(false), |
1288 NULL); | 1280 NULL); |
1289 provider_.UpdateChromePolicy(policy_map_); | 1281 provider_.UpdateChromePolicy(policy_map_); |
1290 #endif // defined(OS_LINUX) && defined(GOOGLE_CHROME_BUILD) | 1282 #endif // defined(OS_LINUX) && defined(GOOGLE_CHROME_BUILD) |
1291 | 1283 |
1292 EXPECT_CALL(provider_, IsInitializationComplete(_)) | 1284 EXPECT_CALL(provider_, IsInitializationComplete(_)) |
1293 .WillRepeatedly(Return(true)); | 1285 .WillRepeatedly(Return(true)); |
1294 policy::BrowserPolicyConnector::SetPolicyProviderForTesting(&provider_); | 1286 policy::BrowserPolicyConnector::SetPolicyProviderForTesting(&provider_); |
1295 #endif // defined(ENABLE_CONFIGURATION_POLICY) | |
1296 } | 1287 } |
1297 | 1288 |
1298 #if defined(GOOGLE_CHROME_BUILD) && defined(OS_MACOSX) | 1289 #if defined(GOOGLE_CHROME_BUILD) && defined(OS_MACOSX) |
1299 // http://crbug.com/314819 | 1290 // http://crbug.com/314819 |
1300 #define MAYBE_SyncPromoForbidden DISABLED_SyncPromoForbidden | 1291 #define MAYBE_SyncPromoForbidden DISABLED_SyncPromoForbidden |
1301 #else | 1292 #else |
1302 #define MAYBE_SyncPromoForbidden SyncPromoForbidden | 1293 #define MAYBE_SyncPromoForbidden SyncPromoForbidden |
1303 #endif | 1294 #endif |
1304 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorFirstRunTest, | 1295 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorFirstRunTest, |
1305 MAYBE_SyncPromoForbidden) { | 1296 MAYBE_SyncPromoForbidden) { |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1611 Browser* new_browser = FindOneOtherBrowser(browser()); | 1602 Browser* new_browser = FindOneOtherBrowser(browser()); |
1612 ASSERT_TRUE(new_browser); | 1603 ASSERT_TRUE(new_browser); |
1613 | 1604 |
1614 // Verify that the first-run tab is shown and no sync promo has been added. | 1605 // Verify that the first-run tab is shown and no sync promo has been added. |
1615 TabStripModel* tab_strip = new_browser->tab_strip_model(); | 1606 TabStripModel* tab_strip = new_browser->tab_strip_model(); |
1616 ASSERT_EQ(1, tab_strip->count()); | 1607 ASSERT_EQ(1, tab_strip->count()); |
1617 EXPECT_EQ("title1.html", | 1608 EXPECT_EQ("title1.html", |
1618 tab_strip->GetWebContentsAt(0)->GetURL().ExtractFileName()); | 1609 tab_strip->GetWebContentsAt(0)->GetURL().ExtractFileName()); |
1619 } | 1610 } |
1620 | 1611 |
1621 #if defined(ENABLE_CONFIGURATION_POLICY) | |
1622 #if defined(GOOGLE_CHROME_BUILD) && defined(OS_MACOSX) | 1612 #if defined(GOOGLE_CHROME_BUILD) && defined(OS_MACOSX) |
1623 // http://crbug.com/314819 | 1613 // http://crbug.com/314819 |
1624 #define MAYBE_RestoreOnStartupURLsPolicySpecified \ | 1614 #define MAYBE_RestoreOnStartupURLsPolicySpecified \ |
1625 DISABLED_RestoreOnStartupURLsPolicySpecified | 1615 DISABLED_RestoreOnStartupURLsPolicySpecified |
1626 #else | 1616 #else |
1627 #define MAYBE_RestoreOnStartupURLsPolicySpecified \ | 1617 #define MAYBE_RestoreOnStartupURLsPolicySpecified \ |
1628 RestoreOnStartupURLsPolicySpecified | 1618 RestoreOnStartupURLsPolicySpecified |
1629 #endif | 1619 #endif |
1630 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorFirstRunTest, | 1620 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorFirstRunTest, |
1631 MAYBE_RestoreOnStartupURLsPolicySpecified) { | 1621 MAYBE_RestoreOnStartupURLsPolicySpecified) { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1672 Browser* new_browser = FindOneOtherBrowser(browser()); | 1662 Browser* new_browser = FindOneOtherBrowser(browser()); |
1673 ASSERT_TRUE(new_browser); | 1663 ASSERT_TRUE(new_browser); |
1674 | 1664 |
1675 // Verify that the URL specified through policy is shown and no sync promo has | 1665 // Verify that the URL specified through policy is shown and no sync promo has |
1676 // been added. | 1666 // been added. |
1677 TabStripModel* tab_strip = new_browser->tab_strip_model(); | 1667 TabStripModel* tab_strip = new_browser->tab_strip_model(); |
1678 ASSERT_EQ(1, tab_strip->count()); | 1668 ASSERT_EQ(1, tab_strip->count()); |
1679 EXPECT_EQ("title1.html", | 1669 EXPECT_EQ("title1.html", |
1680 tab_strip->GetWebContentsAt(0)->GetURL().ExtractFileName()); | 1670 tab_strip->GetWebContentsAt(0)->GetURL().ExtractFileName()); |
1681 } | 1671 } |
1682 #endif // defined(ENABLE_CONFIGURATION_POLICY) | |
1683 | |
1684 #endif // !defined(OS_LINUX) || !defined(GOOGLE_CHROME_BUILD) || | |
1685 // defined(ENABLE_CONFIGURATION_POLICY) | |
1686 | 1672 |
1687 #endif // !defined(OS_CHROMEOS) | 1673 #endif // !defined(OS_CHROMEOS) |
OLD | NEW |