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/autofill/save_card_bubble_controller_impl.h" | 5 #include "chrome/browser/ui/autofill/save_card_bubble_controller_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/ptr_util.h" |
12 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
13 #include "base/test/histogram_tester.h" | 14 #include "base/test/histogram_tester.h" |
14 #include "base/values.h" | 15 #include "base/values.h" |
15 #include "chrome/browser/ui/autofill/save_card_bubble_view.h" | 16 #include "chrome/browser/ui/autofill/save_card_bubble_view.h" |
16 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 17 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
17 #include "chrome/test/base/browser_with_test_window_test.h" | 18 #include "chrome/test/base/browser_with_test_window_test.h" |
18 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 19 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
19 #include "components/autofill/core/browser/autofill_metrics.h" | 20 #include "components/autofill/core/browser/autofill_metrics.h" |
20 #include "components/autofill/core/browser/credit_card.h" | 21 #include "components/autofill/core/browser/credit_card.h" |
21 #include "components/autofill/core/common/autofill_pref_names.h" | 22 #include "components/autofill/core/common/autofill_pref_names.h" |
22 #include "components/user_prefs/user_prefs.h" | 23 #include "components/user_prefs/user_prefs.h" |
23 #include "content/public/browser/navigation_handle.h" | 24 #include "content/public/browser/navigation_handle.h" |
24 #include "testing/gmock/include/gmock/gmock.h" | 25 #include "testing/gmock/include/gmock/gmock.h" |
25 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
26 | 27 |
27 using base::Bucket; | 28 using base::Bucket; |
28 using testing::ElementsAre; | 29 using testing::ElementsAre; |
29 | 30 |
30 namespace autofill { | 31 namespace autofill { |
31 | 32 |
32 class TestSaveCardBubbleControllerImpl : public SaveCardBubbleControllerImpl { | 33 class TestSaveCardBubbleControllerImpl : public SaveCardBubbleControllerImpl { |
33 public: | 34 public: |
34 static void CreateForTesting(content::WebContents* web_contents) { | 35 static void CreateForTesting(content::WebContents* web_contents) { |
35 web_contents->SetUserData( | 36 web_contents->SetUserData( |
36 UserDataKey(), new TestSaveCardBubbleControllerImpl(web_contents)); | 37 UserDataKey(), |
| 38 base::MakeUnique<TestSaveCardBubbleControllerImpl>(web_contents)); |
37 } | 39 } |
38 | 40 |
39 explicit TestSaveCardBubbleControllerImpl(content::WebContents* web_contents) | 41 explicit TestSaveCardBubbleControllerImpl(content::WebContents* web_contents) |
40 : SaveCardBubbleControllerImpl(web_contents) {} | 42 : SaveCardBubbleControllerImpl(web_contents) {} |
41 | 43 |
42 void set_elapsed(base::TimeDelta elapsed) { elapsed_ = elapsed; } | 44 void set_elapsed(base::TimeDelta elapsed) { elapsed_ = elapsed; } |
43 | 45 |
44 void SimulateNavigation() { | 46 void SimulateNavigation() { |
45 content::RenderFrameHost* rfh = web_contents()->GetMainFrame(); | 47 content::RenderFrameHost* rfh = web_contents()->GetMainFrame(); |
46 std::unique_ptr<content::NavigationHandle> navigation_handle = | 48 std::unique_ptr<content::NavigationHandle> navigation_handle = |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 EXPECT_THAT( | 461 EXPECT_THAT( |
460 histogram_tester.GetAllSamples( | 462 histogram_tester.GetAllSamples( |
461 "Autofill.SaveCreditCardPrompt.Upload.FirstShow"), | 463 "Autofill.SaveCreditCardPrompt.Upload.FirstShow"), |
462 ElementsAre( | 464 ElementsAre( |
463 Bucket(AutofillMetrics::SAVE_CARD_PROMPT_SHOW_REQUESTED, 1), | 465 Bucket(AutofillMetrics::SAVE_CARD_PROMPT_SHOW_REQUESTED, 1), |
464 Bucket(AutofillMetrics::SAVE_CARD_PROMPT_END_INVALID_LEGAL_MESSAGE, | 466 Bucket(AutofillMetrics::SAVE_CARD_PROMPT_END_INVALID_LEGAL_MESSAGE, |
465 1))); | 467 1))); |
466 } | 468 } |
467 | 469 |
468 } // namespace autofill | 470 } // namespace autofill |
OLD | NEW |