OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/renderer/chrome_render_frame_observer.h" | 5 #include "chrome/renderer/chrome_render_frame_observer.h" |
6 | 6 |
7 #include <tuple> | 7 #include <tuple> |
8 | 8 |
9 #include "base/test/histogram_tester.h" | 9 #include "base/test/histogram_tester.h" |
10 #include "chrome/test/base/chrome_render_view_test.h" | 10 #include "chrome/test/base/chrome_render_view_test.h" |
11 #include "components/translate/content/common/translate.mojom.h" | 11 #include "components/translate/content/common/translate.mojom.h" |
12 #include "components/translate/content/renderer/translate_helper.h" | 12 #include "components/translate/content/renderer/translate_helper.h" |
13 #include "components/translate/core/common/translate_constants.h" | 13 #include "components/translate/core/common/translate_constants.h" |
14 #include "content/public/renderer/render_frame.h" | 14 #include "content/public/renderer/render_frame.h" |
15 #include "content/public/renderer/render_view.h" | 15 #include "content/public/renderer/render_view.h" |
16 #include "mojo/public/cpp/bindings/binding_set.h" | 16 #include "mojo/public/cpp/bindings/binding_set.h" |
17 #include "services/shell/public/cpp/interface_provider.h" | 17 #include "services/service_manager/public/cpp/interface_provider.h" |
18 #include "third_party/WebKit/public/web/WebView.h" | 18 #include "third_party/WebKit/public/web/WebView.h" |
19 | 19 |
20 namespace { | 20 namespace { |
21 | 21 |
22 class FakeContentTranslateDriver | 22 class FakeContentTranslateDriver |
23 : public translate::mojom::ContentTranslateDriver { | 23 : public translate::mojom::ContentTranslateDriver { |
24 public: | 24 public: |
25 FakeContentTranslateDriver() | 25 FakeContentTranslateDriver() |
26 : called_new_page_(false), page_needs_translation_(false) {} | 26 : called_new_page_(false), page_needs_translation_(false) {} |
27 ~FakeContentTranslateDriver() override {} | 27 ~FakeContentTranslateDriver() override {} |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 view_->GetWebView()->updateAllLifecyclePhases(); | 79 view_->GetWebView()->updateAllLifecyclePhases(); |
80 | 80 |
81 base::RunLoop().RunUntilIdle(); | 81 base::RunLoop().RunUntilIdle(); |
82 ASSERT_TRUE(fake_translate_driver_.called_new_page_); | 82 ASSERT_TRUE(fake_translate_driver_.called_new_page_); |
83 EXPECT_TRUE(fake_translate_driver_.page_needs_translation_) | 83 EXPECT_TRUE(fake_translate_driver_.page_needs_translation_) |
84 << "Page should be translatable."; | 84 << "Page should be translatable."; |
85 // Should have 2 samples: one for preliminary capture, one for final capture. | 85 // Should have 2 samples: one for preliminary capture, one for final capture. |
86 // If there are more, then subframes are being captured more than once. | 86 // If there are more, then subframes are being captured more than once. |
87 histogram_tester.ExpectTotalCount(kTranslateCaptureText, 2); | 87 histogram_tester.ExpectTotalCount(kTranslateCaptureText, 2); |
88 } | 88 } |
OLD | NEW |