AppListModel / AppsGridView: Better error handling for corner cases.
commitaebcdf88e420f281c950d741106e25dcdf0625e3
authormgiuca <mgiuca@chromium.org>
Tue, 30 Sep 2014 03:49:45 +0000 (29 20:49 -0700)
committerCommit bot <commit-bot@chromium.org>
Tue, 30 Sep 2014 03:50:10 +0000 (30 03:50 +0000)
tree5675562a1d70ef0e102e09cdb144bc1340ed7f1b
parente79765c5aaf52bbab8bdfd1780cd39d17894001d
AppListModel / AppsGridView: Better error handling for corner cases.

Fixes a potential crash if an app gets duplicated in the app list, and
the user tries to drop it onto itself. (There is no known way to repro
this currently, but there was recently; see http://crbug.com/415530.)
That situation will now result in a very descriptive DCHECK, rather than
a confusing low-level CHECK fail.

AppListModel::MergeItems:
- returns "" instead of crashing if the source and target IDs are equal.
- returns "" instead of crashing if the target ID is inside a folder (no
  longer needs to explicitly CHECK whether it is in a folder.)

Added plenty of new tests for the various corner cases in
AppListModel::MergeItems which would have caught these crashes.

AppsGridView::MoveItemToFolder:
- DCHECKs for a NULL result of GetViewAtSlotOnCurrentPage.
- DCHECKs that you aren't dropping an item onto itself (this should
  never happen).

BUG=417482

Review URL: https://codereview.chromium.org/600393002

Cr-Commit-Position: refs/heads/master@{#297356}
ui/app_list/app_list_model.cc
ui/app_list/app_list_model_unittest.cc
ui/app_list/views/apps_grid_view.cc