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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
12 #include "chrome/browser/chrome_notification_types.h" | 12 #include "chrome/browser/chrome_notification_types.h" |
13 #include "chrome/browser/chromeos/login/existing_user_controller.h" | 13 #include "chrome/browser/chromeos/login/existing_user_controller.h" |
14 #include "chrome/browser/chromeos/login/test/oobe_base_test.h" | 14 #include "chrome/browser/chromeos/login/test/oobe_base_test.h" |
15 #include "chrome/browser/chromeos/login/ui/webui_login_display.h" | 15 #include "chrome/browser/chromeos/login/ui/webui_login_display.h" |
16 #include "chrome/browser/chromeos/login/wizard_controller.h" | 16 #include "chrome/browser/chromeos/login/wizard_controller.h" |
| 17 #include "chrome/browser/rlz/rlz.h" |
17 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" | 18 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" |
18 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
19 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
20 #include "chrome/test/base/in_process_browser_test.h" | 21 #include "chrome/test/base/in_process_browser_test.h" |
21 #include "chromeos/chromeos_switches.h" | 22 #include "chromeos/chromeos_switches.h" |
22 #include "content/public/browser/notification_service.h" | 23 #include "content/public/browser/notification_service.h" |
23 #include "content/public/test/test_utils.h" | 24 #include "content/public/test/test_utils.h" |
24 #include "google_apis/gaia/fake_gaia.h" | 25 #include "google_apis/gaia/fake_gaia.h" |
25 #include "google_apis/gaia/gaia_switches.h" | 26 #include "google_apis/gaia/gaia_switches.h" |
26 #include "google_apis/gaia/gaia_urls.h" | 27 #include "google_apis/gaia/gaia_urls.h" |
27 #include "net/test/embedded_test_server/embedded_test_server.h" | 28 #include "net/test/embedded_test_server/embedded_test_server.h" |
28 #include "net/test/embedded_test_server/http_response.h" | 29 #include "net/test/embedded_test_server/http_response.h" |
29 #include "testing/gtest/include/gtest/gtest.h" | 30 #include "testing/gtest/include/gtest/gtest.h" |
30 | 31 |
31 #if defined(ENABLE_RLZ) | |
32 #include "components/rlz/rlz_tracker.h" | |
33 #endif | |
34 | |
35 namespace chromeos { | 32 namespace chromeos { |
36 | 33 |
37 namespace { | 34 namespace { |
38 | 35 |
39 #if defined(ENABLE_RLZ) | 36 #if defined(ENABLE_RLZ) |
40 void GetAccessPointRlzInBackgroundThread(rlz_lib::AccessPoint point, | 37 void GetAccessPointRlzInBackgroundThread(rlz_lib::AccessPoint point, |
41 base::string16* rlz) { | 38 base::string16* rlz) { |
42 ASSERT_FALSE(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 39 ASSERT_FALSE(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
43 ASSERT_TRUE(rlz::RLZTracker::GetAccessPointRlz(point, rlz)); | 40 ASSERT_TRUE(RLZTracker::GetAccessPointRlz(point, rlz)); |
44 } | 41 } |
45 #endif | 42 #endif |
46 | 43 |
47 } // namespace | 44 } // namespace |
48 | 45 |
49 class LoginUtilsTest : public OobeBaseTest, | 46 class LoginUtilsTest : public OobeBaseTest, |
50 public testing::WithParamInterface<bool> { | 47 public testing::WithParamInterface<bool> { |
51 public: | 48 public: |
52 LoginUtilsTest() { set_use_webview(GetParam()); } | 49 LoginUtilsTest() { set_use_webview(GetParam()); } |
53 | 50 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 // RLZ brand code has been set to empty string. | 99 // RLZ brand code has been set to empty string. |
103 EXPECT_TRUE(local_state()->HasPrefPath(prefs::kRLZBrand)); | 100 EXPECT_TRUE(local_state()->HasPrefPath(prefs::kRLZBrand)); |
104 EXPECT_EQ(std::string(), local_state()->GetString(prefs::kRLZBrand)); | 101 EXPECT_EQ(std::string(), local_state()->GetString(prefs::kRLZBrand)); |
105 | 102 |
106 // RLZ value for homepage access point should have been initialized. | 103 // RLZ value for homepage access point should have been initialized. |
107 // This value must be obtained in a background thread. | 104 // This value must be obtained in a background thread. |
108 { | 105 { |
109 base::RunLoop loop; | 106 base::RunLoop loop; |
110 base::string16 rlz_string; | 107 base::string16 rlz_string; |
111 content::BrowserThread::PostBlockingPoolTaskAndReply( | 108 content::BrowserThread::PostBlockingPoolTaskAndReply( |
112 FROM_HERE, base::Bind(&GetAccessPointRlzInBackgroundThread, | 109 FROM_HERE, |
113 rlz::RLZTracker::ChromeHomePage(), &rlz_string), | 110 base::Bind(&GetAccessPointRlzInBackgroundThread, |
| 111 RLZTracker::ChromeHomePage(), |
| 112 &rlz_string), |
114 loop.QuitClosure()); | 113 loop.QuitClosure()); |
115 loop.Run(); | 114 loop.Run(); |
116 EXPECT_EQ(base::string16(), rlz_string); | 115 EXPECT_EQ(base::string16(), rlz_string); |
117 } | 116 } |
118 } | 117 } |
119 | 118 |
120 INSTANTIATE_TEST_CASE_P(LoginUtilsTestSuite, LoginUtilsTest, testing::Bool()); | 119 INSTANTIATE_TEST_CASE_P(LoginUtilsTestSuite, LoginUtilsTest, testing::Bool()); |
121 | 120 |
122 #endif | 121 #endif |
123 | 122 |
124 } // namespace chromeos | 123 } // namespace chromeos |
OLD | NEW |