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