| OLD | NEW | 
|    1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |    1 // Copyright (c) 2012 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/browser/ui/bookmarks/recently_used_folders_combo_model.h" |    5 #include "chrome/browser/ui/bookmarks/recently_used_folders_combo_model.h" | 
|    6  |    6  | 
|    7 #include "base/memory/scoped_ptr.h" |    7 #include "base/memory/scoped_ptr.h" | 
|    8 #include "base/message_loop/message_loop.h" |    8 #include "base/message_loop/message_loop.h" | 
|    9 #include "base/strings/utf_string_conversions.h" |    9 #include "base/strings/utf_string_conversions.h" | 
|   10 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |   10 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 
|   11 #include "chrome/test/base/testing_profile.h" |   11 #include "chrome/test/base/testing_profile.h" | 
|   12 #include "components/bookmarks/browser/bookmark_model.h" |   12 #include "components/bookmarks/browser/bookmark_model.h" | 
|   13 #include "components/bookmarks/test/bookmark_test_helpers.h" |   13 #include "components/bookmarks/test/bookmark_test_helpers.h" | 
|   14 #include "content/public/test/test_browser_thread.h" |   14 #include "content/public/test/test_browser_thread.h" | 
|   15 #include "testing/gtest/include/gtest/gtest.h" |   15 #include "testing/gtest/include/gtest/gtest.h" | 
|   16 #include "ui/base/models/combobox_model_observer.h" |   16 #include "ui/base/models/combobox_model_observer.h" | 
|   17  |   17  | 
|   18 using content::BrowserThread; |   18 using content::BrowserThread; | 
|   19  |   19  | 
|   20 // Implementation of ComboboxModelObserver that records when |   20 // Implementation of ComboboxModelObserver that records when | 
|   21 // OnComboboxModelChanged() is invoked. |   21 // OnComboboxModelChanged() is invoked. | 
|   22 class TestComboboxModelObserver : public ui::ComboboxModelObserver { |   22 class TestComboboxModelObserver : public ui::ComboboxModelObserver { | 
|   23  public: |   23  public: | 
|   24   TestComboboxModelObserver() : changed_(false) {} |   24   TestComboboxModelObserver() : changed_(false) {} | 
|   25   virtual ~TestComboboxModelObserver() {} |   25   ~TestComboboxModelObserver() override {} | 
|   26  |   26  | 
|   27   // Returns whether the model changed and clears changed state. |   27   // Returns whether the model changed and clears changed state. | 
|   28   bool GetAndClearChanged() { |   28   bool GetAndClearChanged() { | 
|   29     const bool changed = changed_; |   29     const bool changed = changed_; | 
|   30     changed_ = false; |   30     changed_ = false; | 
|   31     return changed; |   31     return changed; | 
|   32   } |   32   } | 
|   33  |   33  | 
|   34   // ComboboxModelObserver: |   34   // ComboboxModelObserver: | 
|   35   virtual void OnComboboxModelChanged(ui::ComboboxModel* model) override { |   35   void OnComboboxModelChanged(ui::ComboboxModel* model) override { | 
|   36     changed_ = true; |   36     changed_ = true; | 
|   37   } |   37   } | 
|   38  |   38  | 
|   39  private: |   39  private: | 
|   40   bool changed_; |   40   bool changed_; | 
|   41  |   41  | 
|   42   DISALLOW_COPY_AND_ASSIGN(TestComboboxModelObserver); |   42   DISALLOW_COPY_AND_ASSIGN(TestComboboxModelObserver); | 
|   43 }; |   43 }; | 
|   44  |   44  | 
|   45 class RecentlyUsedFoldersComboModelTest : public testing::Test { |   45 class RecentlyUsedFoldersComboModelTest : public testing::Test { | 
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  113   const int updated_count = model.GetItemCount(); |  113   const int updated_count = model.GetItemCount(); | 
|  114   EXPECT_LT(updated_count, initial_count); |  114   EXPECT_LT(updated_count, initial_count); | 
|  115  |  115  | 
|  116   // Remove all, which should remove a folder too. |  116   // Remove all, which should remove a folder too. | 
|  117   GetModel()->RemoveAllUserBookmarks(); |  117   GetModel()->RemoveAllUserBookmarks(); | 
|  118   EXPECT_TRUE(observer.GetAndClearChanged()); |  118   EXPECT_TRUE(observer.GetAndClearChanged()); | 
|  119   EXPECT_LT(model.GetItemCount(), updated_count); |  119   EXPECT_LT(model.GetItemCount(), updated_count); | 
|  120  |  120  | 
|  121   model.RemoveObserver(&observer); |  121   model.RemoveObserver(&observer); | 
|  122 } |  122 } | 
| OLD | NEW |