~azzar1/unity/fix-1028810

« back to all changes in this revision

Viewing changes to tests/test_home_lens.cpp

  • Committer: Andrea Azzarone
  • Date: 2012-08-22 13:14:18 UTC
  • mfrom: (2516.1.92 unity)
  • Revision ID: azzaronea@gmail.com-20120822131418-mrfwx82k39xnvl9e
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
63
63
           ModelType::LOCAL)
64
64
  {
65
65
    search_in_global(true);
 
66
    connected.SetGetterFunction(sigc::mem_fun(this, &StaticTestLens::force_connected));
66
67
 
67
68
    DeeModel* cats = categories()->model();
68
69
    DeeModel* results = global_results()->model();
88
89
 
89
90
  virtual ~StaticTestLens() {}
90
91
 
 
92
  bool force_connected()
 
93
  {
 
94
    return true;
 
95
  }
 
96
 
91
97
  virtual void DoGlobalSearch(string const& search_string)
92
98
  {
93
99
    DeeModel* model = global_results()->model();
258
264
  EXPECT_EQ(home_lens_.GetLensAtIndex(1)->id(), "second.lens");
259
265
}
260
266
 
261
 
TEST(TestHomeLens, TestCategoryMerging)
 
267
TEST(TestHomeLens, TestCategoryMergingDisplayName)
262
268
{
263
 
  HomeLens home_lens_("name", "description", "searchhint");
 
269
  HomeLens home_lens_("name", "description", "searchhint",
 
270
                      HomeLens::MergeMode::DISPLAY_NAME);
264
271
  TwoStaticTestLenses lenses_;
265
272
  DeeModel* cats = home_lens_.categories()->model();
266
273
  DeeModelIter* iter;
292
299
  EXPECT_EQ("cat1+second.lens", string(dee_model_get_string(cats, iter, NAME_COLUMN)));
293
300
}
294
301
 
 
302
TEST(TestHomeLens, TestCategoryMergingPerLens)
 
303
{
 
304
  HomeLens home_lens_("name", "description", "searchhint",
 
305
                      HomeLens::MergeMode::OWNER_LENS);
 
306
  TwoStaticTestLenses lenses_;
 
307
  DeeModel* cats = home_lens_.categories()->model();
 
308
  DeeModelIter* iter;
 
309
  const unsigned int NAME_COLUMN = 0;
 
310
 
 
311
  home_lens_.AddLenses(lenses_);
 
312
 
 
313
  EXPECT_EQ(dee_model_get_n_rows(cats), 2); // just two lenses
 
314
 
 
315
  /* Validate the merged categories */
 
316
  iter = dee_model_get_iter_at_row(cats, 0);
 
317
  EXPECT_EQ("First Lens", string(dee_model_get_string(cats, iter, NAME_COLUMN)));
 
318
 
 
319
  iter = dee_model_get_iter_at_row(cats, 1);
 
320
  EXPECT_EQ("Second Lens", string(dee_model_get_string(cats, iter, NAME_COLUMN)));
 
321
}
 
322
 
295
323
// It's not that we must not support filters. It is just not implemented yet.
296
324
// But we actively test against it to make sure we don't end up with broken
297
325
// filters in the UI. When/if we land support for filters on the home screen
307
335
 
308
336
TEST(TestHomeLens, TestOneSearch)
309
337
{
310
 
  HomeLens home_lens_("name", "description", "searchhint");
 
338
  HomeLens home_lens_("name", "description", "searchhint",
 
339
                      HomeLens::MergeMode::DISPLAY_NAME);
311
340
  TwoStaticTestLenses lenses_;
312
341
  DeeModel* results = home_lens_.results()->model();
313
342
  DeeModel* cats = home_lens_.categories()->model();