OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h" | 5 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/feature_list.h" |
10 #include "base/macros.h" | 11 #include "base/macros.h" |
11 #include "base/metrics/histogram_samples.h" | 12 #include "base/metrics/histogram_samples.h" |
12 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
13 #include "build/build_config.h" | 14 #include "build/build_config.h" |
14 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
15 #include "chrome/browser/ui/passwords/manage_passwords_test.h" | 16 #include "chrome/browser/ui/passwords/manage_passwords_test.h" |
16 #include "chrome/browser/ui/passwords/passwords_model_delegate.h" | 17 #include "chrome/browser/ui/passwords/passwords_model_delegate.h" |
17 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 18 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
18 #include "chrome/browser/ui/views/frame/browser_view.h" | 19 #include "chrome/browser/ui/views/frame/browser_view.h" |
19 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h" | 20 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h" |
20 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_views.h" | 21 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_views.h" |
21 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" | 22 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" |
22 #include "chrome/test/base/interactive_test_utils.h" | 23 #include "chrome/test/base/interactive_test_utils.h" |
23 #include "content/public/browser/notification_types.h" | 24 #include "content/public/browser/notification_types.h" |
24 #include "content/public/browser/render_view_host.h" | 25 #include "content/public/browser/render_view_host.h" |
25 #include "content/public/common/content_switches.h" | 26 #include "content/public/common/content_features.h" |
26 #include "net/url_request/test_url_fetcher_factory.h" | 27 #include "net/url_request/test_url_fetcher_factory.h" |
27 #include "testing/gmock/include/gmock/gmock.h" | 28 #include "testing/gmock/include/gmock/gmock.h" |
28 | 29 |
29 using testing::Eq; | 30 using testing::Eq; |
30 using testing::Field; | 31 using testing::Field; |
31 using testing::_; | 32 using testing::_; |
32 | 33 |
33 namespace { | 34 namespace { |
34 | 35 |
35 const char kDisplayDispositionMetric[] = "PasswordBubble.DisplayDisposition"; | 36 const char kDisplayDispositionMetric[] = "PasswordBubble.DisplayDisposition"; |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 EXPECT_FALSE(IsBubbleShowing()); | 285 EXPECT_FALSE(IsBubbleShowing()); |
285 EXPECT_EQ(1, tab_model->active_index()); | 286 EXPECT_EQ(1, tab_model->active_index()); |
286 SetupPendingPassword(); | 287 SetupPendingPassword(); |
287 EXPECT_TRUE(IsBubbleShowing()); | 288 EXPECT_TRUE(IsBubbleShowing()); |
288 // Back to the first tab. | 289 // Back to the first tab. |
289 tab_model->ActivateTabAt(0, true); | 290 tab_model->ActivateTabAt(0, true); |
290 EXPECT_FALSE(IsBubbleShowing()); | 291 EXPECT_FALSE(IsBubbleShowing()); |
291 } | 292 } |
292 | 293 |
293 IN_PROC_BROWSER_TEST_F(ManagePasswordsBubbleViewTest, AutoSignin) { | 294 IN_PROC_BROWSER_TEST_F(ManagePasswordsBubbleViewTest, AutoSignin) { |
294 // The switch enables the new UI. | 295 base::FeatureList::ClearInstanceForTesting(); |
295 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 296 scoped_ptr<base::FeatureList> feature_list(new base::FeatureList); |
296 switches::kEnableCredentialManagerAPI); | 297 feature_list->InitializeFromCommandLine( |
| 298 features::kCredentialManagementAPI.name, std::string()); |
| 299 base::FeatureList::SetInstance(std::move(feature_list)); |
| 300 ASSERT_TRUE(base::FeatureList::IsEnabled(features::kCredentialManagementAPI)); |
| 301 |
297 ScopedVector<autofill::PasswordForm> local_credentials; | 302 ScopedVector<autofill::PasswordForm> local_credentials; |
298 test_form()->origin = GURL("https://example.com"); | 303 test_form()->origin = GURL("https://example.com"); |
299 test_form()->display_name = base::ASCIIToUTF16("Peter"); | 304 test_form()->display_name = base::ASCIIToUTF16("Peter"); |
300 test_form()->username_value = base::ASCIIToUTF16("pet12@gmail.com"); | 305 test_form()->username_value = base::ASCIIToUTF16("pet12@gmail.com"); |
301 GURL icon_url("https://google.com/icon.png"); | 306 GURL icon_url("https://google.com/icon.png"); |
302 test_form()->icon_url = icon_url; | 307 test_form()->icon_url = icon_url; |
303 local_credentials.push_back(new autofill::PasswordForm(*test_form())); | 308 local_credentials.push_back(new autofill::PasswordForm(*test_form())); |
304 | 309 |
305 // Prepare to capture the network request. | 310 // Prepare to capture the network request. |
306 TestURLFetcherCallback url_callback; | 311 TestURLFetcherCallback url_callback; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 content::RunAllPendingInMessageLoop(); | 347 content::RunAllPendingInMessageLoop(); |
343 EXPECT_TRUE(IsBubbleShowing()); | 348 EXPECT_TRUE(IsBubbleShowing()); |
344 | 349 |
345 // Bring the first window back. The toast closes by timeout. | 350 // Bring the first window back. The toast closes by timeout. |
346 focused_window->window()->Close(); | 351 focused_window->window()->Close(); |
347 browser()->window()->Activate(); | 352 browser()->window()->Activate(); |
348 content::RunAllPendingInMessageLoop(); | 353 content::RunAllPendingInMessageLoop(); |
349 EXPECT_TRUE(browser()->window()->IsActive()); | 354 EXPECT_TRUE(browser()->window()->IsActive()); |
350 EXPECT_FALSE(IsBubbleShowing()); | 355 EXPECT_FALSE(IsBubbleShowing()); |
351 } | 356 } |
OLD | NEW |