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 package org.chromium.chrome.browser.ntp.snippets; | 5 package org.chromium.chrome.browser.ntp.snippets; |
6 | 6 |
7 import android.graphics.BitmapFactory; | 7 import android.graphics.BitmapFactory; |
8 import android.test.suitebuilder.annotation.MediumTest; | 8 import android.test.suitebuilder.annotation.MediumTest; |
9 import android.util.TypedValue; | 9 import android.util.TypedValue; |
10 import android.view.ContextMenu; | 10 import android.view.ContextMenu; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 public ArticleSnippetsTest() { | 54 public ArticleSnippetsTest() { |
55 super(ChromeActivity.class); | 55 super(ChromeActivity.class); |
56 } | 56 } |
57 | 57 |
58 @MediumTest | 58 @MediumTest |
59 @Feature({"ArticleSnippets", "RenderTest"}) | 59 @Feature({"ArticleSnippets", "RenderTest"}) |
60 public void testSnippetAppearance() throws IOException { | 60 public void testSnippetAppearance() throws IOException { |
61 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 61 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
62 @Override | 62 @Override |
63 public void run() { | 63 public void run() { |
| 64 setupTestData(); |
| 65 |
64 mContentView = new FrameLayout(getActivity()); | 66 mContentView = new FrameLayout(getActivity()); |
65 mUiConfig = new UiConfig(mContentView); | 67 mUiConfig = new UiConfig(mContentView); |
66 | 68 |
67 getActivity().setContentView(mContentView); | 69 getActivity().setContentView(mContentView); |
68 | 70 |
69 mRecyclerView = (NewTabPageRecyclerView) getActivity().getLayout
Inflater() | 71 mRecyclerView = (NewTabPageRecyclerView) getActivity().getLayout
Inflater() |
70 .inflate(R.layout.new_tab_page_recycler_view, mContentVi
ew, false); | 72 .inflate(R.layout.new_tab_page_recycler_view, mContentVi
ew, false); |
71 mContentView.addView(mRecyclerView); | 73 mContentView.addView(mRecyclerView); |
72 | 74 |
73 View aboveTheFold = new View(getActivity()); | 75 View aboveTheFold = new View(getActivity()); |
74 | 76 |
75 | |
76 mRecyclerView.setAboveTheFoldView(aboveTheFold); | 77 mRecyclerView.setAboveTheFoldView(aboveTheFold); |
77 mAdapter = new NewTabPageAdapter(mNtpManager, aboveTheFold, mSni
ppetsSource, | 78 mAdapter = new NewTabPageAdapter(mNtpManager, aboveTheFold, mSni
ppetsSource, |
78 mUiConfig); | 79 mUiConfig); |
79 mRecyclerView.setAdapter(mAdapter); | 80 mRecyclerView.setAdapter(mAdapter); |
80 | |
81 setupTestData(); | |
82 } | 81 } |
83 }); | 82 }); |
84 | 83 |
85 getInstrumentation().waitForIdleSync(); | 84 getInstrumentation().waitForIdleSync(); |
86 | 85 |
87 int first = mAdapter.getFirstCardPosition(); | 86 int first = mAdapter.getFirstCardPosition(); |
88 mViewRenderer.renderAndCompare(mRecyclerView.getChildAt(first), "short_s
nippet"); | 87 mViewRenderer.renderAndCompare(mRecyclerView.getChildAt(first), "short_s
nippet"); |
89 mViewRenderer.renderAndCompare(mRecyclerView.getChildAt(first + 1), "lon
g_snippet"); | 88 mViewRenderer.renderAndCompare(mRecyclerView.getChildAt(first + 1), "lon
g_snippet"); |
90 mViewRenderer.renderAndCompare(mRecyclerView.getChildAt(first + 2), "min
imal_snippet"); | 89 mViewRenderer.renderAndCompare(mRecyclerView.getChildAt(first + 2), "min
imal_snippet"); |
91 mViewRenderer.renderAndCompare(mRecyclerView, "snippets"); | 90 mViewRenderer.renderAndCompare(mRecyclerView, "snippets"); |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 public void addContextMenuCloseCallback(Callback<Menu> callback) { | 327 public void addContextMenuCloseCallback(Callback<Menu> callback) { |
329 throw new UnsupportedOperationException(); | 328 throw new UnsupportedOperationException(); |
330 } | 329 } |
331 | 330 |
332 @Override | 331 @Override |
333 public void removeContextMenuCloseCallback(Callback<Menu> callback) { | 332 public void removeContextMenuCloseCallback(Callback<Menu> callback) { |
334 throw new UnsupportedOperationException(); | 333 throw new UnsupportedOperationException(); |
335 } | 334 } |
336 } | 335 } |
337 } | 336 } |
OLD | NEW |