0

Fix some instances of -Wshadow.

Bug: 794619
Change-Id: Id9c07ff7a273f695ba0869fc622447b134527c1a
AX-Relnotes: n/a.
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3095650
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Reviewed-by: Sadrul Chowdhury <sadrul@chromium.org>
Reviewed-by: Joshua Bell <jsbell@chromium.org>
Reviewed-by: Charlie Harrison <csharrison@chromium.org>
Cr-Commit-Position: refs/heads/master@{#912780}
This commit is contained in:
Peter Kasting
2021-08-17 22:45:40 +00:00
committed by Chromium LUCI CQ
parent af91de0150
commit a45490cf8d
38 changed files with 279 additions and 286 deletions

@ -91,8 +91,7 @@ class DataPipeConsumerHelper {
while (current_offset_ < max_bytes_to_read_) {
const void* data;
uint32_t size;
MojoResult result =
pipe_->BeginReadData(&data, &size, MOJO_READ_DATA_FLAG_NONE);
result = pipe_->BeginReadData(&data, &size, MOJO_READ_DATA_FLAG_NONE);
if (result == MOJO_RESULT_SHOULD_WAIT) {
watcher_.ArmOrNotify();
return;

@ -388,8 +388,7 @@ TEST_F(DraggedFileUtilTest, ReadDirectoryTest) {
file_system_context(), url, &entries));
EXPECT_EQ(expected_entry_map.size(), entries.size());
for (size_t i = 0; i < entries.size(); ++i) {
const filesystem::mojom::DirectoryEntry& entry = entries[i];
for (const auto& entry : entries) {
auto found = expected_entry_map.find(entry.name.value());
EXPECT_TRUE(found != expected_entry_map.end());
EXPECT_EQ(found->second.name, entry.name);

@ -210,7 +210,6 @@ TEST_F(FileSystemContextTest, CrackFileSystemURL) {
"ext", kFileSystemTypeLocal, FileSystemMountOption(),
base::FilePath(DRIVE FPL("/test/local/ext/"))));
const GURL kTestOrigin = GURL("http://chromium.org/");
const base::FilePath kVirtualPathNoRoot = base::FilePath(FPL("root/file"));
struct TestCase {

@ -539,9 +539,9 @@ base::File::Error ObfuscatedFileUtil::CopyOrMoveFile(
base::File::Info dest_platform_file_info; // overwrite case only
base::FilePath dest_local_path; // overwrite case only
if (overwrite) {
base::File::Error error = GetFileInfoInternal(
db, context, dest_url, dest_file_id, &dest_file_info,
&dest_platform_file_info, &dest_local_path);
error = GetFileInfoInternal(db, context, dest_url, dest_file_id,
&dest_file_info, &dest_platform_file_info,
&dest_local_path);
if (error == base::File::FILE_ERROR_NOT_FOUND)
overwrite = false; // fallback to non-overwrite case
else if (error != base::File::FILE_OK)

@ -2013,7 +2013,6 @@ TEST_P(ObfuscatedFileUtilTest, TestFileEnumeratorTimestamp) {
while (!(file_path_each = file_enum->Next()).empty()) {
context = NewContext(nullptr);
base::File::Info file_info;
base::FilePath file_path;
EXPECT_EQ(base::File::FILE_OK,
ofu()->GetFileInfo(
context.get(),

@ -357,7 +357,6 @@ bool DatabaseCheckHelper::ScanHierarchy() {
return false;
// Check if the child knows the parent as its parent.
FileInfo file_info;
if (!dir_db_->GetFileInfo(id, &file_info))
return false;
if (file_info.parent_id != dir_id)

@ -256,10 +256,10 @@ void ClientUsageTracker::DidGetStorageKeysForGlobalUsage(
for (const auto& host_and_storage_keys : storage_keys_by_host) {
const std::string& host = host_and_storage_keys.first;
const std::vector<blink::StorageKey>& storage_keys =
const std::vector<blink::StorageKey>& storage_keys_for_host =
host_and_storage_keys.second;
if (host_usage_accumulators_.Add(host, accumulator))
GetUsageForStorageKeys(host, storage_keys);
GetUsageForStorageKeys(host, storage_keys_for_host);
}
// Fire the sentinel as we've now called GetUsageForStorageKeys for all

@ -543,7 +543,6 @@ TEST(AXEventGeneratorTest, SelectionInTextFieldChanged) {
ASSERT_THAT(event_generator, IsEmpty());
{
AXTreeData tree_data;
tree_data.sel_anchor_object_id = text_field.id;
tree_data.sel_anchor_offset = 0;
tree_data.sel_focus_object_id = text_field.id;
@ -567,7 +566,6 @@ TEST(AXEventGeneratorTest, SelectionInTextFieldChanged) {
{
// A selection that does not include a text field in it should not raise the
// "SELECTION_IN_TEXT_FIELD_CHANGED" event.
AXTreeData tree_data;
tree_data.sel_anchor_object_id = root.id;
tree_data.sel_anchor_offset = 0;
tree_data.sel_focus_object_id = root.id;
@ -588,7 +586,6 @@ TEST(AXEventGeneratorTest, SelectionInTextFieldChanged) {
// A selection that spans more than one node but which nevertheless ends on
// a text field should still raise the "SELECTION_IN_TEXT_FIELD_CHANGED"
// event.
AXTreeData tree_data;
tree_data.sel_anchor_object_id = root.id;
tree_data.sel_anchor_offset = 0;
tree_data.sel_focus_object_id = text_field.id;

@ -4428,27 +4428,27 @@ TEST_F(AXPositionTest, CreatePositionAtTextBoundaryContentStartEndIsIgnored) {
// | +-inline_box_data_3
// +-static_text_data_4
// +-inline_box_data_4 IGNORED
constexpr AXNodeID ROOT_ID = 1;
constexpr AXNodeID STATIC_TEXT1_ID = 2;
constexpr AXNodeID STATIC_TEXT2_ID = 3;
constexpr AXNodeID STATIC_TEXT3_ID = 4;
constexpr AXNodeID STATIC_TEXT4_ID = 5;
constexpr AXNodeID INLINE_BOX1_ID = 6;
constexpr AXNodeID INLINE_BOX2_ID = 7;
constexpr AXNodeID INLINE_BOX3_ID = 8;
constexpr AXNodeID INLINE_BOX4_ID = 9;
constexpr AXNodeID kRootId = 1;
constexpr AXNodeID kStaticText1Id = 2;
constexpr AXNodeID kStaticText2Id = 3;
constexpr AXNodeID kStaticText3Id = 4;
constexpr AXNodeID kStaticText4Id = 5;
constexpr AXNodeID kInlineBox1Id = 6;
constexpr AXNodeID kInlineBox2Id = 7;
constexpr AXNodeID kInlineBox3Id = 8;
constexpr AXNodeID kInlineBox4Id = 9;
AXNodeData root_data;
root_data.id = ROOT_ID;
root_data.id = kRootId;
root_data.role = ax::mojom::Role::kRootWebArea;
AXNodeData static_text_data_1;
static_text_data_1.id = STATIC_TEXT1_ID;
static_text_data_1.id = kStaticText1Id;
static_text_data_1.role = ax::mojom::Role::kStaticText;
static_text_data_1.SetName("One");
AXNodeData inline_box_data_1;
inline_box_data_1.id = INLINE_BOX1_ID;
inline_box_data_1.id = kInlineBox1Id;
inline_box_data_1.role = ax::mojom::Role::kInlineTextBox;
inline_box_data_1.SetName("One");
inline_box_data_1.AddState(ax::mojom::State::kIgnored);
@ -4457,15 +4457,15 @@ TEST_F(AXPositionTest, CreatePositionAtTextBoundaryContentStartEndIsIgnored) {
inline_box_data_1.AddIntListAttribute(ax::mojom::IntListAttribute::kWordEnds,
std::vector<int32_t>{3});
inline_box_data_1.AddIntAttribute(ax::mojom::IntAttribute::kNextOnLineId,
INLINE_BOX2_ID);
kInlineBox2Id);
AXNodeData static_text_data_2;
static_text_data_2.id = STATIC_TEXT2_ID;
static_text_data_2.id = kStaticText2Id;
static_text_data_2.role = ax::mojom::Role::kStaticText;
static_text_data_2.SetName("Two");
AXNodeData inline_box_data_2;
inline_box_data_2.id = INLINE_BOX2_ID;
inline_box_data_2.id = kInlineBox2Id;
inline_box_data_2.role = ax::mojom::Role::kInlineTextBox;
inline_box_data_2.SetName("Two");
inline_box_data_2.AddIntListAttribute(
@ -4473,17 +4473,17 @@ TEST_F(AXPositionTest, CreatePositionAtTextBoundaryContentStartEndIsIgnored) {
inline_box_data_2.AddIntListAttribute(ax::mojom::IntListAttribute::kWordEnds,
std::vector<int32_t>{3});
inline_box_data_2.AddIntAttribute(ax::mojom::IntAttribute::kPreviousOnLineId,
INLINE_BOX1_ID);
kInlineBox1Id);
inline_box_data_2.AddIntAttribute(ax::mojom::IntAttribute::kNextOnLineId,
INLINE_BOX3_ID);
kInlineBox3Id);
AXNodeData static_text_data_3;
static_text_data_3.id = STATIC_TEXT3_ID;
static_text_data_3.id = kStaticText3Id;
static_text_data_3.role = ax::mojom::Role::kStaticText;
static_text_data_3.SetName("Three");
AXNodeData inline_box_data_3;
inline_box_data_3.id = INLINE_BOX3_ID;
inline_box_data_3.id = kInlineBox3Id;
inline_box_data_3.role = ax::mojom::Role::kInlineTextBox;
inline_box_data_3.SetName("Three");
inline_box_data_3.AddIntListAttribute(
@ -4491,17 +4491,17 @@ TEST_F(AXPositionTest, CreatePositionAtTextBoundaryContentStartEndIsIgnored) {
inline_box_data_3.AddIntListAttribute(ax::mojom::IntListAttribute::kWordEnds,
std::vector<int32_t>{5});
inline_box_data_3.AddIntAttribute(ax::mojom::IntAttribute::kPreviousOnLineId,
INLINE_BOX2_ID);
kInlineBox2Id);
inline_box_data_3.AddIntAttribute(ax::mojom::IntAttribute::kNextOnLineId,
INLINE_BOX4_ID);
kInlineBox4Id);
AXNodeData static_text_data_4;
static_text_data_4.id = STATIC_TEXT4_ID;
static_text_data_4.id = kStaticText4Id;
static_text_data_4.role = ax::mojom::Role::kStaticText;
static_text_data_4.SetName("Four");
AXNodeData inline_box_data_4;
inline_box_data_4.id = INLINE_BOX4_ID;
inline_box_data_4.id = kInlineBox4Id;
inline_box_data_4.role = ax::mojom::Role::kInlineTextBox;
inline_box_data_4.SetName("Four");
inline_box_data_4.AddState(ax::mojom::State::kIgnored);
@ -4510,7 +4510,7 @@ TEST_F(AXPositionTest, CreatePositionAtTextBoundaryContentStartEndIsIgnored) {
inline_box_data_3.AddIntListAttribute(ax::mojom::IntListAttribute::kWordEnds,
std::vector<int32_t>{4});
inline_box_data_3.AddIntAttribute(ax::mojom::IntAttribute::kPreviousOnLineId,
INLINE_BOX3_ID);
kInlineBox3Id);
root_data.child_ids = {static_text_data_1.id, static_text_data_2.id,
static_text_data_3.id, static_text_data_4.id};

@ -858,10 +858,9 @@ gfx::RectF AXTree::RelativeToTreeBoundsInternal(const AXNode* node,
if (ancestor && allow_recursion) {
bool ignore_offscreen;
bool allow_recursion = false;
ancestor_bounds = RelativeToTreeBoundsInternal(
ancestor, gfx::RectF(), &ignore_offscreen, clip_bounds,
allow_recursion);
/* allow_recursion = */ false);
gfx::RectF original_bounds = original_node->data().relative_bounds.bounds;
if (original_bounds.x() == 0 && original_bounds.y() == 0) {

@ -185,11 +185,13 @@ HRESULT AXPlatformNodeTextRangeProviderWin::ExpandToEnclosingUnit(
HRESULT AXPlatformNodeTextRangeProviderWin::ExpandToEnclosingUnitImpl(
TextUnit unit) {
UIA_VALIDATE_TEXTRANGEPROVIDER_CALL();
AXPositionInstance normalized_start = start()->Clone();
AXPositionInstance normalized_end = end()->Clone();
NormalizeTextRange(normalized_start, normalized_end);
SetStart(std::move(normalized_start));
SetEnd(std::move(normalized_end));
{
AXPositionInstance normalized_start = start()->Clone();
AXPositionInstance normalized_end = end()->Clone();
NormalizeTextRange(normalized_start, normalized_end);
SetStart(std::move(normalized_start));
SetEnd(std::move(normalized_end));
}
// Determine if start is on a boundary of the specified TextUnit, if it is
// not, move backwards until it is. Move the end forwards from start until it

@ -3143,7 +3143,7 @@ TEST_F(AXPlatformNodeTextRangeProviderTest,
Init(update);
ComPtr<ITextRangeProvider> text_range_provider;
base::win::ScopedSafearray rectangles;
int count;
int units_moved;
// Expected bounding rects:
// <button>Button</button><input type="checkbox">Line 1<br>Line 2
@ -3163,8 +3163,9 @@ TEST_F(AXPlatformNodeTextRangeProviderTest,
// <button>Button</button><input type="checkbox">Line 1<br>Line 2
// |---------------------||---------------------||----| |----|
ASSERT_HRESULT_SUCCEEDED(text_range_provider->MoveEndpointByUnit(
TextPatternRangeEndpoint_End, TextUnit_Character, /*count*/ -1, &count));
ASSERT_EQ(-1, count);
TextPatternRangeEndpoint_End, TextUnit_Character, /*count*/ -1,
&units_moved));
ASSERT_EQ(-1, units_moved);
EXPECT_HRESULT_SUCCEEDED(
text_range_provider->GetBoundingRectangles(rectangles.Receive()));
expected_values = {20, 20, 200, 30, /* button */
@ -3179,8 +3180,8 @@ TEST_F(AXPlatformNodeTextRangeProviderTest,
// <button>Button</button><input type="checkbox">Line 1<br>Line 2
// |---------------------||---------------------||--------|
ASSERT_HRESULT_SUCCEEDED(text_range_provider->MoveEndpointByUnit(
TextPatternRangeEndpoint_End, TextUnit_Line, /*count*/ -1, &count));
ASSERT_EQ(-1, count);
TextPatternRangeEndpoint_End, TextUnit_Line, /*count*/ -1, &units_moved));
ASSERT_EQ(-1, units_moved);
EXPECT_HRESULT_SUCCEEDED(
text_range_provider->GetBoundingRectangles(rectangles.Receive()));
expected_values = {20, 20, 200, 30, /* button */
@ -3194,8 +3195,8 @@ TEST_F(AXPlatformNodeTextRangeProviderTest,
// <button>Button</button><input type="checkbox">Line 1<br>Line 2
// |---------------------||---------------------|
ASSERT_HRESULT_SUCCEEDED(text_range_provider->MoveEndpointByUnit(
TextPatternRangeEndpoint_End, TextUnit_Word, /*count*/ -3, &count));
ASSERT_EQ(-3, count);
TextPatternRangeEndpoint_End, TextUnit_Word, /*count*/ -3, &units_moved));
ASSERT_EQ(-3, units_moved);
EXPECT_HRESULT_SUCCEEDED(
text_range_provider->GetBoundingRectangles(rectangles.Receive()));
expected_values = {20, 20, 200, 30, /* button */

@ -3448,17 +3448,17 @@ TEST_F(GestureRecognizerTest, GestureEventTripleTap) {
ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&release3);
// Third, Fourth and Fifth Taps. Taps after the third should have their
// Fourth, Fifth, and Sixth Taps. Taps after the third should have their
// |tap_count| wrap around back to 1.
for (int i = 3; i < 5; ++i) {
ui::TouchEvent press3(
for (int i = 4; i < 6; ++i) {
ui::TouchEvent press4(
ui::ET_TOUCH_PRESSED, gfx::Point(102, 206), tes.LeapForward(200),
ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&press3);
ui::TouchEvent release3(
DispatchEventUsingWindowDispatcher(&press4);
ui::TouchEvent release4(
ui::ET_TOUCH_RELEASED, gfx::Point(102, 206), tes.LeapForward(50),
ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&release3);
DispatchEventUsingWindowDispatcher(&release4);
EXPECT_TRUE(delegate->tap());
EXPECT_TRUE(delegate->tap_down());
@ -3468,7 +3468,7 @@ TEST_F(GestureRecognizerTest, GestureEventTripleTap) {
EXPECT_FALSE(delegate->scroll_begin());
EXPECT_FALSE(delegate->scroll_update());
EXPECT_FALSE(delegate->scroll_end());
EXPECT_EQ(1 + (i % 3), delegate->tap_count());
EXPECT_EQ(i % 3, delegate->tap_count());
}
}

@ -70,9 +70,8 @@ HWND TestWin32Window::Create(DWORD style) {
wcex.lpszClassName = class_name;
wcex.style = CS_HREDRAW | CS_VREDRAW;
RegisterClassEx(&wcex);
HWND hwnd_ =
CreateWindowEx(0, class_name, class_name, style, 0, 0, 100, 100, nullptr,
nullptr, GetModuleHandle(nullptr), nullptr);
hwnd_ = CreateWindowEx(0, class_name, class_name, style, 0, 0, 100, 100,
nullptr, nullptr, GetModuleHandle(nullptr), nullptr);
ShowWindow(hwnd_, SW_SHOWNORMAL);
EXPECT_TRUE(UpdateWindow(hwnd_));
return hwnd_;

@ -436,12 +436,12 @@ void TestClipboard::DataStore::Clear() {
}
void TestClipboard::DataStore::SetDataSource(
std::unique_ptr<DataTransferEndpoint> data_src) {
this->data_src = std::move(data_src);
std::unique_ptr<DataTransferEndpoint> new_data_src) {
data_src = std::move(new_data_src);
}
DataTransferEndpoint* TestClipboard::DataStore::GetDataSource() const {
return this->data_src.get();
return data_src.get();
}
const TestClipboard::DataStore& TestClipboard::GetStore(

@ -122,7 +122,7 @@ class TestClipboard : public Clipboard {
DataStore& operator=(const DataStore& other);
~DataStore();
void Clear();
void SetDataSource(std::unique_ptr<DataTransferEndpoint> data_src);
void SetDataSource(std::unique_ptr<DataTransferEndpoint> new_data_src);
DataTransferEndpoint* GetDataSource() const;
ClipboardSequenceNumberToken sequence_number;
base::flat_map<ClipboardFormatType, std::string> data;

@ -491,14 +491,13 @@ HRESULT TSFBridgeImpl::InitializeDocumentMapInternal() {
DWORD* cookie_ptr = use_null_text_store ? nullptr : &cookie;
scoped_refptr<TSFTextStore> text_store =
use_null_text_store ? nullptr : new TSFTextStore();
HRESULT hr = S_OK;
if (text_store) {
HRESULT hr = text_store->Initialize();
if (FAILED(hr))
return hr;
}
hr = CreateDocumentManager(text_store.get(), &document_manager, &context,
cookie_ptr);
HRESULT hr = CreateDocumentManager(text_store.get(), &document_manager,
&context, cookie_ptr);
if (FAILED(hr))
return hr;
if (input_type == TEXT_INPUT_TYPE_PASSWORD) {

@ -43,7 +43,7 @@ TableColumn& TableColumn::operator=(const TableColumn& other) = default;
// TableModel -----------------------------------------------------------------
// Used for sorting.
static icu::Collator* collator = NULL;
static icu::Collator* g_collator = NULL;
ui::ImageModel TableModel::GetIcon(int row) {
return ui::ImageModel();
@ -68,20 +68,20 @@ int TableModel::CompareValues(int row1, int row2, int column_id) {
}
void TableModel::ClearCollator() {
delete collator;
collator = NULL;
delete g_collator;
g_collator = NULL;
}
icu::Collator* TableModel::GetCollator() {
if (!collator) {
if (!g_collator) {
UErrorCode create_status = U_ZERO_ERROR;
collator = icu::Collator::createInstance(create_status);
g_collator = icu::Collator::createInstance(create_status);
if (!U_SUCCESS(create_status)) {
collator = NULL;
g_collator = NULL;
NOTREACHED();
}
}
return collator;
return g_collator;
}
} // namespace ui

@ -579,8 +579,8 @@ bool DataPack::WritePack(const base::FilePath& path,
// We place an extra entry after the last item that allows us to read the
// size of the last item.
const uint16_t resource_id = 0;
file.Write(&resource_id, sizeof(resource_id));
const uint16_t extra_resource_id = 0;
file.Write(&extra_resource_id, sizeof(extra_resource_id));
file.Write(&data_offset, sizeof(data_offset));
// Write the aliases table, if any. Note: |aliases| is an std::map,

@ -45,8 +45,8 @@ void DisplayChangeNotifier::NotifyDisplaysChanged(
const std::vector<Display>& new_displays) {
bool did_remove_displays = false;
// Display present in old_displays but not in new_displays has been removed.
auto old_it = old_displays.begin();
for (; old_it != old_displays.end(); ++old_it) {
for (auto old_it = old_displays.begin(); old_it != old_displays.end();
++old_it) {
if (std::find_if(new_displays.begin(), new_displays.end(),
DisplayComparator(*old_it)) == new_displays.end()) {
did_remove_displays = true;

@ -467,13 +467,15 @@ void EdidParser::ParseEdid(const std::vector<uint8_t>& edid) {
if (edid[offset] == 0 && edid[offset + 1] == 0 && edid[offset + 2] == 0 &&
edid[offset + 3] == kMonitorSerialNumberDescriptor &&
edid[offset + 4] == 0) {
std::string serial_number(
std::string serial_number_str(
reinterpret_cast<const char*>(&edid[offset + 5]),
kDescriptorLength - 5);
base::TrimWhitespaceASCII(serial_number, base::TRIM_TRAILING,
&serial_number);
if (!serial_number.empty())
descriptor_block_serial_number_hash_ = base::MD5String(serial_number);
base::TrimWhitespaceASCII(serial_number_str, base::TRIM_TRAILING,
&serial_number_str);
if (!serial_number_str.empty()) {
descriptor_block_serial_number_hash_ =
base::MD5String(serial_number_str);
}
continue;
}
}
@ -588,9 +590,9 @@ void EdidParser::ParseEdid(const std::vector<uint8_t>& edid) {
static_assert(
kMaxNumColorimetryEntries == base::size(kPrimaryIDMap),
"kPrimaryIDMap should describe all possible colorimetry entries");
for (size_t i = 0; i < kMaxNumColorimetryEntries; ++i) {
if (supported_primaries_bitfield[i])
supported_color_primary_ids_.insert(kPrimaryIDMap[i]);
for (size_t entry = 0; entry < kMaxNumColorimetryEntries; ++entry) {
if (supported_primaries_bitfield[entry])
supported_color_primary_ids_.insert(kPrimaryIDMap[entry]);
}
break;
}
@ -602,9 +604,10 @@ void EdidParser::ParseEdid(const std::vector<uint8_t>& edid) {
static_assert(
kMaxNumHDRStaticMedatataEntries == base::size(kTransferIDMap),
"kTransferIDMap should describe all possible transfer entries");
for (size_t i = 0; i < kMaxNumHDRStaticMedatataEntries; ++i) {
if (supported_eotfs_bitfield[i])
supported_color_transfer_ids_.insert(kTransferIDMap[i]);
for (size_t entry = 0; entry < kMaxNumHDRStaticMedatataEntries;
++entry) {
if (supported_eotfs_bitfield[entry])
supported_color_transfer_ids_.insert(kTransferIDMap[entry]);
}
// See CEA 861.3-2015, Sec.7.5.13, "HDR Static Metadata Data Block"

@ -144,7 +144,7 @@ TEST_F(PlatformEventTest, DispatcherBasic) {
{
TestPlatformEventDispatcher dispatcher(1, &list_dispatcher);
std::unique_ptr<PlatformEvent> event = CreatePlatformEvent();
event = CreatePlatformEvent();
source()->Dispatch(*event);
ASSERT_EQ(1u, list_dispatcher.size());
EXPECT_EQ(1, list_dispatcher[0]);
@ -202,7 +202,7 @@ TEST_F(PlatformEventTest, ObserverBasic) {
{
TestPlatformEventObserver observer(31, &list_observer);
std::unique_ptr<PlatformEvent> event = CreatePlatformEvent();
event = CreatePlatformEvent();
source()->Dispatch(*event);
ASSERT_EQ(1u, list_observer.size());
EXPECT_EQ(31, list_observer[0]);

@ -13,8 +13,6 @@
namespace gfx {
namespace {
const float kEpsilon = 1.0e-3f;
// Returns the L-infty difference of u and v.
float Diff(const skia::Vector4& u, const skia::Vector4& v) {
float result = 0;
@ -24,6 +22,7 @@ float Diff(const skia::Vector4& u, const skia::Vector4& v) {
}
TEST(ColorSpace, RGBToYUV) {
const float kEpsilon = 1.0e-3f;
const size_t kNumTestRGBs = 3;
skia::Vector4 test_rgbs[kNumTestRGBs] = {
skia::Vector4(1.f, 0.f, 0.f, 1.f),
@ -84,6 +83,7 @@ TEST(ColorSpace, RGBToYUV) {
}
TEST(ColorSpace, RangeAdjust) {
const float kEpsilon = 1.0e-3f;
const size_t kNumTestYUVs = 2;
skia::Vector4 test_yuvs[kNumTestYUVs] = {
skia::Vector4(1.f, 1.f, 1.f, 1.f),
@ -280,6 +280,7 @@ TEST(ColorSpace, HLGToSkColorSpace) {
ColorSpace color_space;
ColorSpace roundtrip_color_space;
float roundtrip_sdr_white_level;
const float kEpsilon = 1.0e-3f;
// We expect that when a white point is specified, the conversion from
// ColorSpace -> SkColorSpace -> ColorSpace be the identity. Because of

@ -17,9 +17,6 @@
namespace gfx {
// Allowed pixel error.
const float kPixelEpsilon = 1.5f / 255.f;
// Allowed math error.
const float kMathEpsilon = 0.001f;
@ -349,6 +346,7 @@ TEST(SimpleColorSpace, ICCProfileOnlyColorSpin) {
}
TEST(SimpleColorSpace, GetColorSpace) {
const float kPixelEpsilon = 1.5f / 255.f;
ICCProfile srgb_icc = ICCProfileForTestingSRGB();
ColorSpace sRGB = srgb_icc.GetColorSpace();
ColorSpace sRGB2 = sRGB;
@ -382,6 +380,7 @@ TEST(SimpleColorSpace, GetColorSpace) {
}
TEST(SimpleColorSpace, Scale) {
const float kPixelEpsilon = 1.5f / 255.f;
ColorSpace srgb = ColorSpace::CreateSRGB();
ColorSpace srgb_scaled = srgb.GetScaledColorSpace(2.0f);
std::unique_ptr<ColorTransform> t(

@ -1018,44 +1018,44 @@ TEST(RectTest, ManhattanInternalDistance) {
TEST(RectTest, IntegerOverflow) {
int limit = std::numeric_limits<int>::max();
int min_limit = std::numeric_limits<int>::min();
int expected = 10;
int large_number = limit - expected;
int expected_thickness = 10;
int large_number = limit - expected_thickness;
Rect height_overflow(0, large_number, 100, 100);
EXPECT_EQ(large_number, height_overflow.y());
EXPECT_EQ(expected, height_overflow.height());
EXPECT_EQ(expected_thickness, height_overflow.height());
Rect width_overflow(large_number, 0, 100, 100);
EXPECT_EQ(large_number, width_overflow.x());
EXPECT_EQ(expected, width_overflow.width());
EXPECT_EQ(expected_thickness, width_overflow.width());
Rect size_height_overflow(Point(0, large_number), Size(100, 100));
EXPECT_EQ(large_number, size_height_overflow.y());
EXPECT_EQ(expected, size_height_overflow.height());
EXPECT_EQ(expected_thickness, size_height_overflow.height());
Rect size_width_overflow(Point(large_number, 0), Size(100, 100));
EXPECT_EQ(large_number, size_width_overflow.x());
EXPECT_EQ(expected, size_width_overflow.width());
EXPECT_EQ(expected_thickness, size_width_overflow.width());
Rect set_height_overflow(0, large_number, 100, 5);
EXPECT_EQ(5, set_height_overflow.height());
set_height_overflow.set_height(100);
EXPECT_EQ(expected, set_height_overflow.height());
EXPECT_EQ(expected_thickness, set_height_overflow.height());
Rect set_y_overflow(100, 100, 100, 100);
EXPECT_EQ(100, set_y_overflow.height());
set_y_overflow.set_y(large_number);
EXPECT_EQ(expected, set_y_overflow.height());
EXPECT_EQ(expected_thickness, set_y_overflow.height());
Rect set_width_overflow(large_number, 0, 5, 100);
EXPECT_EQ(5, set_width_overflow.width());
set_width_overflow.set_width(100);
EXPECT_EQ(expected, set_width_overflow.width());
EXPECT_EQ(expected_thickness, set_width_overflow.width());
Rect set_x_overflow(100, 100, 100, 100);
EXPECT_EQ(100, set_x_overflow.width());
set_x_overflow.set_x(large_number);
EXPECT_EQ(expected, set_x_overflow.width());
EXPECT_EQ(expected_thickness, set_x_overflow.width());
Point large_offset(large_number, large_number);
Size size(100, 100);
@ -1147,8 +1147,8 @@ TEST(RectTest, IntegerOverflow) {
// Ideally, this should be (100, 100, limit + 400, limit + 400).
// However, width overflows and would be clamped to limit, but right
// overflows too and so will be clamped to limit - 100.
Rect expected(100, 100, limit - 100, limit - 100);
EXPECT_EQ(UnionRects(clamped, positive_origin), expected);
Rect expected_rect(100, 100, limit - 100, limit - 100);
EXPECT_EQ(UnionRects(clamped, positive_origin), expected_rect);
}
// Unioning a left=minint rect with a right=maxint rect.
@ -1158,7 +1158,7 @@ TEST(RectTest, IntegerOverflow) {
int part_limit = min_limit / 3;
Rect left_minint(min_limit, min_limit, 1, 1);
Rect right_maxint(limit - 1, limit - 1, limit, limit);
Rect expected(part_limit, part_limit, 2 * part_limit, 2 * part_limit);
Rect expected_rect(part_limit, part_limit, 2 * part_limit, 2 * part_limit);
Rect result = UnionRects(left_minint, right_maxint);
// The result should be maximally big.
@ -1172,7 +1172,7 @@ TEST(RectTest, IntegerOverflow) {
EXPECT_LT(part_limit, result.bottom());
// More succinctly, but harder to read in the results.
EXPECT_TRUE(UnionRects(left_minint, right_maxint).Contains(expected));
EXPECT_TRUE(UnionRects(left_minint, right_maxint).Contains(expected_rect));
}
}

@ -398,7 +398,7 @@ Microsoft::WRL::ComPtr<ID3D11Texture2D> SwapChainPresenter::UploadVideoImages(
desc.Usage = D3D11_USAGE_DEFAULT;
desc.BindFlags = D3D11_BIND_DECODER;
desc.CPUAccessFlags = 0;
HRESULT hr = d3d11_device_->CreateTexture2D(&desc, nullptr, &copy_texture_);
hr = d3d11_device_->CreateTexture2D(&desc, nullptr, &copy_texture_);
if (FAILED(hr)) {
DLOG(ERROR) << "Creating D3D11 video upload texture failed: " << std::hex
<< hr;

@ -98,14 +98,13 @@ bool VSyncProviderWin::GetVSyncParametersIfAvailable(
HMONITOR monitor = MonitorFromWindow(window_, MONITOR_DEFAULTTONEAREST);
MONITORINFOEX monitor_info;
monitor_info.cbSize = sizeof(MONITORINFOEX);
BOOL result = GetMonitorInfo(monitor, &monitor_info);
if (result) {
if (GetMonitorInfo(monitor, &monitor_info)) {
DEVMODE display_info;
display_info.dmSize = sizeof(DEVMODE);
display_info.dmDriverExtra = 0;
result = EnumDisplaySettings(monitor_info.szDevice, ENUM_CURRENT_SETTINGS,
&display_info);
if (result && display_info.dmDisplayFrequency > 1) {
if (EnumDisplaySettings(monitor_info.szDevice, ENUM_CURRENT_SETTINGS,
&display_info) &&
display_info.dmDisplayFrequency > 1) {
interval = base::TimeDelta::FromMicroseconds(
(1.0 / static_cast<double>(display_info.dmDisplayFrequency)) *
base::Time::kMicrosecondsPerSecond);

@ -1033,49 +1033,52 @@ TEST_F(MessageCenterImplTest, FindNotificationsByAppId) {
message_center()->SetHasMessageCenterView(true);
const std::string app_id1("app_id1");
const std::string id1("id1");
// Add a notification for |app_id1|.
std::unique_ptr<Notification> notification =
CreateNotificationWithNotifierId(id1, app_id1, NOTIFICATION_TYPE_SIMPLE);
message_center()->AddNotification(std::move(notification));
EXPECT_EQ(1u, message_center()->FindNotificationsByAppId(app_id1).size());
// Mark the notification as shown but not read.
message_center()->MarkSinglePopupAsShown(id1, false);
EXPECT_EQ(1u, message_center()->FindNotificationsByAppId(app_id1).size());
// Mark the notification as shown and read.
message_center()->MarkSinglePopupAsShown(id1, true);
EXPECT_EQ(1u, message_center()->FindNotificationsByAppId(app_id1).size());
// Remove the notification.
message_center()->RemoveNotification(id1, true);
EXPECT_EQ(0u, message_center()->FindNotificationsByAppId(app_id1).size());
// Add two notifications for |app_id1|.
notification =
CreateNotificationWithNotifierId(id1, app_id1, NOTIFICATION_TYPE_SIMPLE);
message_center()->AddNotification(std::move(notification));
const std::string id2("id2");
notification =
CreateNotificationWithNotifierId(id2, app_id1, NOTIFICATION_TYPE_SIMPLE);
message_center()->AddNotification(std::move(notification));
EXPECT_EQ(2u, message_center()->FindNotificationsByAppId(app_id1).size());
// Remove |id2|,there should only be one notification for |app_id1|.
message_center()->RemoveNotification(id2, true);
EXPECT_EQ(1u, message_center()->FindNotificationsByAppId(app_id1).size());
// Add a notification for |app_id2|.
const std::string app_id2("app_id2");
const std::string id3("id3");
notification =
CreateNotificationWithNotifierId(id3, app_id2, NOTIFICATION_TYPE_SIMPLE);
message_center()->AddNotification(std::move(notification));
EXPECT_EQ(1u, message_center()->FindNotificationsByAppId(app_id1).size());
EXPECT_EQ(1u, message_center()->FindNotificationsByAppId(app_id2).size());
{
// Add a notification for |app_id1|.
const std::string id1("id1");
std::unique_ptr<Notification> notification =
CreateNotificationWithNotifierId(id1, app_id1,
NOTIFICATION_TYPE_SIMPLE);
message_center()->AddNotification(std::move(notification));
EXPECT_EQ(1u, message_center()->FindNotificationsByAppId(app_id1).size());
// Mark the notification as shown but not read.
message_center()->MarkSinglePopupAsShown(id1, false);
EXPECT_EQ(1u, message_center()->FindNotificationsByAppId(app_id1).size());
// Mark the notification as shown and read.
message_center()->MarkSinglePopupAsShown(id1, true);
EXPECT_EQ(1u, message_center()->FindNotificationsByAppId(app_id1).size());
// Remove the notification.
message_center()->RemoveNotification(id1, true);
EXPECT_EQ(0u, message_center()->FindNotificationsByAppId(app_id1).size());
// Add two notifications for |app_id1|.
notification = CreateNotificationWithNotifierId(id1, app_id1,
NOTIFICATION_TYPE_SIMPLE);
message_center()->AddNotification(std::move(notification));
const std::string id2("id2");
notification = CreateNotificationWithNotifierId(id2, app_id1,
NOTIFICATION_TYPE_SIMPLE);
message_center()->AddNotification(std::move(notification));
EXPECT_EQ(2u, message_center()->FindNotificationsByAppId(app_id1).size());
// Remove |id2|,there should only be one notification for |app_id1|.
message_center()->RemoveNotification(id2, true);
EXPECT_EQ(1u, message_center()->FindNotificationsByAppId(app_id1).size());
// Add a notification for |app_id2|.
const std::string id3("id3");
notification = CreateNotificationWithNotifierId(id3, app_id2,
NOTIFICATION_TYPE_SIMPLE);
message_center()->AddNotification(std::move(notification));
EXPECT_EQ(1u, message_center()->FindNotificationsByAppId(app_id1).size());
EXPECT_EQ(1u, message_center()->FindNotificationsByAppId(app_id2).size());
}
for (std::string app_id : {app_id1, app_id2}) {
for (auto* notification :

@ -300,8 +300,8 @@ TEST_F(NotificationListTest, OldPopupShouldNotBeHidden) {
EXPECT_EQ(ids[i], (*iter)->id()) << i;
}
for (auto iter = popups.begin(); iter != popups.end(); ++iter) {
notification_list_->MarkSinglePopupAsShown((*iter)->id(), false);
for (auto* popup : popups) {
notification_list_->MarkSinglePopupAsShown(popup->id(), false);
}
popups.clear();
popups = GetPopups();
@ -351,52 +351,59 @@ TEST_F(NotificationListTest, Priority) {
// Tests that GetNotificationsByAppId returns notifications regardless of their
// visibility.
TEST_F(NotificationListTest, GetNotificationsByAppId) {
// Add a notification for |app_id1|.
const std::string app_id1("app_id1");
const std::string id1("id1");
std::unique_ptr<Notification> notification(new Notification(
NOTIFICATION_TYPE_PROGRESS, id1, u"updated", u"updated", gfx::Image(),
std::u16string(), GURL(), NotifierId(NotifierType::APPLICATION, app_id1),
RichNotificationData(), nullptr));
notification_list_->AddNotification(std::move(notification));
EXPECT_EQ(1u, notification_list_->GetNotificationsByAppId(app_id1).size());
// Mark the popup as shown but not read.
notification_list_->MarkSinglePopupAsShown(id1, false);
EXPECT_EQ(1u, notification_list_->GetNotificationsByAppId(app_id1).size());
// Mark the popup as shown and read.
notification_list_->MarkSinglePopupAsShown(id1, true);
EXPECT_EQ(1u, notification_list_->GetNotificationsByAppId(app_id1).size());
// Remove the notification.
notification_list_->RemoveNotification(id1);
EXPECT_EQ(0u, notification_list_->GetNotificationsByAppId(app_id1).size());
// Add two notifications for |app_id1| and one for |app_id2|.
notification = std::make_unique<Notification>(
NOTIFICATION_TYPE_PROGRESS, id1, u"updated", u"updated", gfx::Image(),
std::u16string(), GURL(), NotifierId(NotifierType::APPLICATION, app_id1),
RichNotificationData(), nullptr);
notification_list_->AddNotification(std::move(notification));
const std::string id2("id2");
notification = std::make_unique<Notification>(
NOTIFICATION_TYPE_PROGRESS, id2, u"updated", u"updated", gfx::Image(),
std::u16string(), GURL(), NotifierId(NotifierType::APPLICATION, app_id1),
RichNotificationData(), nullptr);
notification_list_->AddNotification(std::move(notification));
EXPECT_EQ(2u, notification_list_->GetNotificationsByAppId(app_id1).size());
const std::string id3("id3");
const std::string app_id2("app_id2");
notification = std::make_unique<Notification>(
NOTIFICATION_TYPE_PROGRESS, id3, u"updated", u"updated", gfx::Image(),
std::u16string(), GURL(), NotifierId(NotifierType::APPLICATION, app_id2),
RichNotificationData(), nullptr);
notification_list_->AddNotification(std::move(notification));
EXPECT_EQ(2u, notification_list_->GetNotificationsByAppId(app_id1).size());
EXPECT_EQ(1u, notification_list_->GetNotificationsByAppId(app_id2).size());
{
// Add a notification for |app_id1|.
const std::string id1("id1");
std::unique_ptr<Notification> notification(
new Notification(NOTIFICATION_TYPE_PROGRESS, id1, u"updated",
u"updated", gfx::Image(), std::u16string(), GURL(),
NotifierId(NotifierType::APPLICATION, app_id1),
RichNotificationData(), nullptr));
notification_list_->AddNotification(std::move(notification));
EXPECT_EQ(1u, notification_list_->GetNotificationsByAppId(app_id1).size());
// Mark the popup as shown but not read.
notification_list_->MarkSinglePopupAsShown(id1, false);
EXPECT_EQ(1u, notification_list_->GetNotificationsByAppId(app_id1).size());
// Mark the popup as shown and read.
notification_list_->MarkSinglePopupAsShown(id1, true);
EXPECT_EQ(1u, notification_list_->GetNotificationsByAppId(app_id1).size());
// Remove the notification.
notification_list_->RemoveNotification(id1);
EXPECT_EQ(0u, notification_list_->GetNotificationsByAppId(app_id1).size());
// Add two notifications for |app_id1| and one for |app_id2|.
notification = std::make_unique<Notification>(
NOTIFICATION_TYPE_PROGRESS, id1, u"updated", u"updated", gfx::Image(),
std::u16string(), GURL(),
NotifierId(NotifierType::APPLICATION, app_id1), RichNotificationData(),
nullptr);
notification_list_->AddNotification(std::move(notification));
const std::string id2("id2");
notification = std::make_unique<Notification>(
NOTIFICATION_TYPE_PROGRESS, id2, u"updated", u"updated", gfx::Image(),
std::u16string(), GURL(),
NotifierId(NotifierType::APPLICATION, app_id1), RichNotificationData(),
nullptr);
notification_list_->AddNotification(std::move(notification));
EXPECT_EQ(2u, notification_list_->GetNotificationsByAppId(app_id1).size());
const std::string id3("id3");
notification = std::make_unique<Notification>(
NOTIFICATION_TYPE_PROGRESS, id3, u"updated", u"updated", gfx::Image(),
std::u16string(), GURL(),
NotifierId(NotifierType::APPLICATION, app_id2), RichNotificationData(),
nullptr);
notification_list_->AddNotification(std::move(notification));
EXPECT_EQ(2u, notification_list_->GetNotificationsByAppId(app_id1).size());
EXPECT_EQ(1u, notification_list_->GetNotificationsByAppId(app_id2).size());
}
for (std::string app_id : {app_id1, app_id2}) {
for (auto* notification :

@ -142,8 +142,7 @@ void PopupTimersController::OnNotificationUpdated(const std::string& id) {
// If a timer was paused before, pause it afterwards as well.
// See crbug.com/710298
if (was_paused) {
auto timer = popup_timers_.find(id);
timer->second->Pause();
popup_timers_.find(id)->second->Pause();
}
}

@ -462,40 +462,34 @@ TEST_F(NotificationViewMDTest, UpdateViewsOrderingTest) {
TEST_F(NotificationViewMDTest, TestIconSizing) {
// TODO(tetsui): Remove duplicated integer literal in CreateOrUpdateIconView.
const int kNotificationIconSize = 36;
const int kIconSize = 36;
std::unique_ptr<Notification> notification = CreateSimpleNotification();
notification->set_type(NOTIFICATION_TYPE_SIMPLE);
ProportionalImageView* view = notification_view()->icon_view_;
// Icons smaller than the maximum size should remain unscaled.
notification->set_icon(
CreateTestImage(kNotificationIconSize / 2, kNotificationIconSize / 4));
notification->set_icon(CreateTestImage(kIconSize / 2, kIconSize / 4));
UpdateNotificationViews(*notification);
EXPECT_EQ(gfx::Size(kNotificationIconSize / 2, kNotificationIconSize / 4)
.ToString(),
EXPECT_EQ(gfx::Size(kIconSize / 2, kIconSize / 4).ToString(),
GetImagePaintSize(view).ToString());
// Icons of exactly the intended icon size should remain unscaled.
notification->set_icon(
CreateTestImage(kNotificationIconSize, kNotificationIconSize));
notification->set_icon(CreateTestImage(kIconSize, kIconSize));
UpdateNotificationViews(*notification);
EXPECT_EQ(gfx::Size(kNotificationIconSize, kNotificationIconSize).ToString(),
EXPECT_EQ(gfx::Size(kIconSize, kIconSize).ToString(),
GetImagePaintSize(view).ToString());
// Icons over the maximum size should be scaled down, maintaining proportions.
notification->set_icon(
CreateTestImage(2 * kNotificationIconSize, 2 * kNotificationIconSize));
notification->set_icon(CreateTestImage(2 * kIconSize, 2 * kIconSize));
UpdateNotificationViews(*notification);
EXPECT_EQ(gfx::Size(kNotificationIconSize, kNotificationIconSize).ToString(),
EXPECT_EQ(gfx::Size(kIconSize, kIconSize).ToString(),
GetImagePaintSize(view).ToString());
notification->set_icon(
CreateTestImage(4 * kNotificationIconSize, 2 * kNotificationIconSize));
notification->set_icon(CreateTestImage(4 * kIconSize, 2 * kIconSize));
UpdateNotificationViews(*notification);
EXPECT_EQ(
gfx::Size(kNotificationIconSize, kNotificationIconSize / 2).ToString(),
GetImagePaintSize(view).ToString());
EXPECT_EQ(gfx::Size(kIconSize, kIconSize / 2).ToString(),
GetImagePaintSize(view).ToString());
}
TEST_F(NotificationViewMDTest, UpdateButtonsStateTest) {
@ -1106,12 +1100,11 @@ TEST_F(NotificationViewMDTest, TestAccentColor) {
TEST_F(NotificationViewMDTest, UseImageAsIcon) {
// TODO(tetsui): Remove duplicated integer literal in CreateOrUpdateIconView.
const int kNotificationIconSize = 30;
const int kIconSize = 30;
std::unique_ptr<Notification> notification = CreateSimpleNotification();
notification->set_type(NotificationType::NOTIFICATION_TYPE_IMAGE);
notification->set_icon(
CreateTestImage(kNotificationIconSize, kNotificationIconSize));
notification->set_icon(CreateTestImage(kIconSize, kIconSize));
// Test normal notification.
UpdateNotificationViews(*notification);
@ -1158,7 +1151,7 @@ TEST_F(NotificationViewMDTest, NotificationWithoutIcon) {
}
TEST_F(NotificationViewMDTest, UpdateAddingIcon) {
const int kNotificationIconSize = 30;
const int kIconSize = 30;
// Create a notification without an icon.
std::unique_ptr<Notification> notification = CreateSimpleNotification();
@ -1170,8 +1163,7 @@ TEST_F(NotificationViewMDTest, UpdateAddingIcon) {
const int left_content_width = notification_view()->left_content_->width();
// Update the notification, adding an icon.
notification->set_icon(
CreateTestImage(kNotificationIconSize, kNotificationIconSize));
notification->set_icon(CreateTestImage(kIconSize, kIconSize));
UpdateNotificationViews(*notification);
// Notification should now have an icon.

@ -363,15 +363,15 @@ TEST_F(BubbleBorderTest, GetBoundsOriginTest) {
kAnchor.y() + (kAnchor.height() - kTotalSize.height()) / 2},
};
for (size_t i = 0; i < base::size(cases); ++i) {
SCOPED_TRACE(base::StringPrintf("shadow=%d i=%d arrow=%d",
for (size_t j = 0; j < base::size(cases); ++j) {
SCOPED_TRACE(base::StringPrintf("shadow=%d j=%d arrow=%d",
static_cast<int>(shadow),
static_cast<int>(i), cases[i].arrow));
const BubbleBorder::Arrow arrow = cases[i].arrow;
static_cast<int>(j), cases[j].arrow));
const BubbleBorder::Arrow arrow = cases[j].arrow;
border.set_arrow(arrow);
gfx::Point origin = border.GetBounds(kAnchor, kContentSize).origin();
EXPECT_EQ(cases[i].expected_x, origin.x());
EXPECT_EQ(cases[i].expected_y, origin.y());
EXPECT_EQ(cases[j].expected_x, origin.x());
EXPECT_EQ(cases[j].expected_y, origin.y());
}
}
}

@ -1510,8 +1510,6 @@ TEST_F(ScrollViewTest, ArrowKeyScrollingDisabled) {
// Test that overflow indicators turn on appropriately.
TEST_F(ScrollViewTest, VerticalOverflowIndicators) {
const int kWidth = 100;
ScrollViewTestApi test_api(scroll_view_.get());
// Set up with vertical scrollbar.
@ -1573,7 +1571,6 @@ TEST_F(ScrollViewTest, VerticalOverflowIndicators) {
}
TEST_F(ScrollViewTest, HorizontalOverflowIndicators) {
const int kWidth = 100;
const int kHeight = 100;
ScrollViewTestApi test_api(scroll_view_.get());
@ -1637,7 +1634,6 @@ TEST_F(ScrollViewTest, HorizontalOverflowIndicators) {
}
TEST_F(ScrollViewTest, HorizontalVerticalOverflowIndicators) {
const int kWidth = 100;
const int kHeight = 100;
ScrollViewTestApi test_api(scroll_view_.get());
@ -1761,8 +1757,6 @@ TEST_F(ScrollViewTest, HorizontalVerticalOverflowIndicators) {
}
TEST_F(ScrollViewTest, VerticalWithHeaderOverflowIndicators) {
const int kWidth = 100;
ScrollViewTestApi test_api(scroll_view_.get());
// Set up with vertical scrollbar and a header.
@ -1829,7 +1823,6 @@ TEST_F(ScrollViewTest, VerticalWithHeaderOverflowIndicators) {
}
TEST_F(ScrollViewTest, CustomOverflowIndicator) {
const int kWidth = 100;
const int kHeight = 100;
ScrollViewTestApi test_api(scroll_view_.get());

@ -475,9 +475,8 @@ void TextfieldTest::PrepareTextfieldsInternal(int count,
test_api_ = std::make_unique<TextfieldTestApi>(textfield);
for (int i = 1; i < count; ++i) {
Textfield* textfield =
container->AddChildView(std::make_unique<Textfield>());
textfield->SetID(i + 1);
Textfield* child = container->AddChildView(std::make_unique<Textfield>());
child->SetID(i + 1);
}
model_ = test_api_->model();

@ -1236,14 +1236,16 @@ TEST_F(ViewTest, PaintInPromotedToLayer) {
v2->SetBounds(3, 4, 6, 5);
v1->AddChildView(v2);
// Paint everything once, since it has to build its cache. Then we can test
// invalidation.
gfx::Rect first_paint(1, 1);
auto list = base::MakeRefCounted<cc::DisplayItemList>();
v1->Paint(PaintInfo::CreateRootPaintInfo(
ui::PaintContext(list.get(), 1.f, first_paint, false), v1->size()));
v1->Reset();
v2->Reset();
{
// Paint everything once, since it has to build its cache. Then we can test
// invalidation.
gfx::Rect first_paint(1, 1);
auto list = base::MakeRefCounted<cc::DisplayItemList>();
v1->Paint(PaintInfo::CreateRootPaintInfo(
ui::PaintContext(list.get(), 1.f, first_paint, false), v1->size()));
v1->Reset();
v2->Reset();
}
{
gfx::Rect paint_area(25, 26);
@ -2888,26 +2890,28 @@ TEST_F(ViewTest, ConversionsWithTransform) {
// View used to test a rotation transform.
TestView* child_2 = new TestView;
top_view.AddChildView(child);
child->AddChildView(child_child);
{
top_view.AddChildView(child);
child->AddChildView(child_child);
top_view.SetBoundsRect(gfx::Rect(0, 0, 1000, 1000));
top_view.SetBoundsRect(gfx::Rect(0, 0, 1000, 1000));
child->SetBoundsRect(gfx::Rect(7, 19, 500, 500));
gfx::Transform transform;
transform.Scale(3.0, 4.0);
child->SetTransform(transform);
child->SetBoundsRect(gfx::Rect(7, 19, 500, 500));
gfx::Transform transform;
transform.Scale(3.0, 4.0);
child->SetTransform(transform);
child_child->SetBoundsRect(gfx::Rect(17, 13, 100, 100));
transform.MakeIdentity();
transform.Scale(5.0, 7.0);
child_child->SetTransform(transform);
child_child->SetBoundsRect(gfx::Rect(17, 13, 100, 100));
transform.MakeIdentity();
transform.Scale(5.0, 7.0);
child_child->SetTransform(transform);
top_view.AddChildView(child_2);
child_2->SetBoundsRect(gfx::Rect(700, 725, 100, 100));
transform.MakeIdentity();
RotateClockwise(&transform);
child_2->SetTransform(transform);
top_view.AddChildView(child_2);
child_2->SetBoundsRect(gfx::Rect(700, 725, 100, 100));
transform.MakeIdentity();
RotateClockwise(&transform);
child_2->SetTransform(transform);
}
// Sanity check to make sure basic transforms act as expected.
{

@ -386,8 +386,8 @@ bool FocusController::SetActiveWindow(
MAYBE_ACTIVATION_INTERRUPTED();
for (auto& observer : activation_observers_) {
observer.OnWindowActivated(
for (auto& activation_observer : activation_observers_) {
activation_observer.OnWindowActivated(
reason, active_window_,
window_tracker.Contains(lost_activation) ? lost_activation : nullptr);

@ -704,17 +704,19 @@ TEST_F(OriginTest, SerializeTBDNonce) {
EXPECT_EQ(origin.GetDebugString(), deserialized.value().GetDebugString());
}
// Same basic test as above, but without a GURL to create tuple_.
Origin opaque;
absl::optional<std::string> serialized = SerializeWithNonce(opaque);
ASSERT_TRUE(serialized);
{
// Same basic test as above, but without a GURL to create tuple_.
Origin opaque;
absl::optional<std::string> serialized = SerializeWithNonce(opaque);
ASSERT_TRUE(serialized);
absl::optional<Origin> deserialized = Deserialize(std::move(*serialized));
ASSERT_TRUE(deserialized.has_value());
absl::optional<Origin> deserialized = Deserialize(std::move(*serialized));
ASSERT_TRUE(deserialized.has_value());
// Can't use DoEqualityComparisons here since empty nonces are never == unless
// they are the same object.
EXPECT_EQ(opaque.GetDebugString(), deserialized.value().GetDebugString());
// Can't use DoEqualityComparisons here since empty nonces are never ==
// unless they are the same object.
EXPECT_EQ(opaque.GetDebugString(), deserialized.value().GetDebugString());
}
// Now force initialization of the nonce prior to serialization.
for (const GURL& url : invalid_urls) {

@ -491,7 +491,7 @@ TEST(URLParser, ExtractFileName) {
struct FileCase {
const char* input;
const char* expected;
} file_cases[] = {
} extract_cases[] = {
{"http://www.google.com", nullptr},
{"http://www.google.com/", ""},
{"http://www.google.com/search", "search"},
@ -509,8 +509,8 @@ TEST(URLParser, ExtractFileName) {
{"http://www.google.com/foo;bar;html", "foo"},
};
for (size_t i = 0; i < base::size(file_cases); i++) {
const char* url = file_cases[i].input;
for (size_t i = 0; i < base::size(extract_cases); i++) {
const char* url = extract_cases[i].input;
int len = static_cast<int>(strlen(url));
Parsed parsed;
@ -519,7 +519,7 @@ TEST(URLParser, ExtractFileName) {
Component file_name;
ExtractFileName(url, parsed.path, &file_name);
EXPECT_TRUE(ComponentMatches(url, file_cases[i].expected, file_name));
EXPECT_TRUE(ComponentMatches(url, extract_cases[i].expected, file_name));
}
}