Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4755)

Unified Diff: chrome/browser/extensions/extensions_service_unittest.cc

Issue 13258: Fix extensions_service_unittest on Linux.... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 12 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extensions_service_unittest.cc
===================================================================
--- chrome/browser/extensions/extensions_service_unittest.cc (revision 6781)
+++ chrome/browser/extensions/extensions_service_unittest.cc (working copy)
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <algorithm>
#include <vector>
#include "base/file_path.h"
@@ -9,13 +10,23 @@
#include "base/message_loop.h"
#include "base/path_service.h"
#include "base/string_util.h"
+#include "chrome/browser/extensions/extension.h"
#include "chrome/browser/extensions/extensions_service.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/json_value_serializer.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
+namespace {
+struct ExtensionsOrder {
+ bool operator()(const Extension* a, const Extension* b) {
+ return a->name() < b->name();
+ }
+};
+
+} // namespace
+
// A mock implementation of ExtensionsServiceFrontendInterface for testing the
// backend.
class ExtensionsServiceTestFrontend
@@ -49,6 +60,9 @@
extensions_.insert(extensions_.end(), new_extensions->begin(),
new_extensions->end());
delete new_extensions;
+ // In the tests we rely on extensions being in particular order,
+ // which is not always the case (and is not guaranteed by used APIs).
+ std::stable_sort(extensions_.begin(), extensions_.end(), ExtensionsOrder());
}
private:
@@ -79,7 +93,7 @@
// Note: There can be more errors if there are extra directories, like .svn
// directories.
EXPECT_TRUE(frontend->errors()->size() >= 2u);
- EXPECT_EQ(2u, frontend->extensions()->size());
+ ASSERT_EQ(2u, frontend->extensions()->size());
EXPECT_EQ(std::wstring(L"com.google.myextension1"),
frontend->extensions()->at(0)->id());
@@ -87,7 +101,7 @@
frontend->extensions()->at(0)->name());
EXPECT_EQ(std::wstring(L"The first extension that I made."),
frontend->extensions()->at(0)->description());
- EXPECT_EQ(2u, frontend->extensions()->at(0)->content_scripts().size());
+ ASSERT_EQ(2u, frontend->extensions()->at(0)->content_scripts().size());
EXPECT_EQ(std::wstring(L"script1.user.js"),
frontend->extensions()->at(0)->content_scripts().at(0));
EXPECT_EQ(std::wstring(L"script2.user.js"),
@@ -99,5 +113,5 @@
frontend->extensions()->at(1)->name());
EXPECT_EQ(std::wstring(L""),
frontend->extensions()->at(1)->description());
- EXPECT_EQ(0u, frontend->extensions()->at(1)->content_scripts().size());
+ ASSERT_EQ(0u, frontend->extensions()->at(1)->content_scripts().size());
};
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698